/* --- Sasa Gallery Variables --- */
:root {
    --sg-font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --sg-primary: #4f46e5;
    
    /* Light Theme Defaults */
    --sg-bg-card: #ffffff;
    --sg-text-main: #111827;
    --sg-text-muted: #6b7280;
    --sg-border: #e5e7eb;
    --sg-shadow: rgba(0, 0, 0, 0.1);
    
    --sg-radius: 12px;
    --sg-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Theme Scopes --- */
.sg-theme-dark {
    --sg-bg-card: #1f2937;
    --sg-text-main: #f9fafb;
    --sg-text-muted: #9ca3af;
    --sg-border: #374151;
    --sg-shadow: rgba(0, 0, 0, 0.3);
}

/* --- Gallery Container --- */
.sg-gallery {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--sg-font-family);
    
    /* Default Column vars (overridden by JS) */
    --sg-cols-mobile: 1;
    --sg-cols-desktop: 3;
}

.sg-loading, .sg-error {
    text-align: center;
    padding: 40px;
    color: var(--sg-text-muted);
    font-size: 0.9rem;
}

.sg-error { color: #ef4444; }

/* --- Layouts --- */

/* Masonry */
.sg-layout-masonry {
    column-count: var(--sg-cols-mobile);
    column-gap: 20px;
}

@media (min-width: 768px) {
    .sg-layout-masonry {
        column-count: var(--sg-cols-desktop);
    }
}

.sg-layout-masonry .sg-card {
    display: inline-block;
    width: 100%;
    margin-bottom: 20px;
    /* Prevent split across columns */
    break-inside: avoid; 
}

/* Grid */
.sg-layout-grid {
    display: grid;
    grid-template-columns: repeat(var(--sg-cols-mobile), 1fr);
    gap: 24px;
}

@media (min-width: 768px) {
    .sg-layout-grid {
        grid-template-columns: repeat(var(--sg-cols-desktop), 1fr);
    }
}

.sg-layout-grid .sg-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Catalog */
.sg-layout-catalog {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.sg-layout-catalog .sg-card {
    display: flex;
    flex-direction: row;
    height: auto;
}
.sg-layout-catalog .sg-thumb-wrapper {
    width: 35%;
    min-width: 200px;
    aspect-ratio: 16/9;
}
.sg-layout-catalog .sg-content {
    width: 65%;
}
@media (max-width: 640px) {
    .sg-layout-catalog .sg-card { flex-direction: column; }
    .sg-layout-catalog .sg-thumb-wrapper { width: 100%; }
    .sg-layout-catalog .sg-content { width: 100%; }
}

/* --- Card Styles --- */
.sg-card {
    background: var(--sg-bg-card);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--sg-transition), box-shadow var(--sg-transition);
    position: relative;
    box-sizing: border-box;
}

.sg-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px var(--sg-shadow), 0 8px 10px -6px var(--sg-shadow);
    border-color: var(--sg-primary);
}

.sg-thumb-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
}

.sg-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.sg-card:hover .sg-thumb {
    transform: scale(1.05);
}

.sg-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.sg-card:hover .sg-play-overlay {
    background: rgba(0,0,0,0.3);
}

.sg-play-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0.9;
    transition: transform 0.3s, background 0.3s;
}

.sg-card:hover .sg-play-icon {
    transform: scale(1.1);
    background: rgba(255,255,255,0.4);
    opacity: 1;
}

.sg-play-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-left: 2px;
}

.sg-content {
    padding: 16px;
}

.sg-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--sg-text-main);
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sg-card:hover .sg-title {
    color: var(--sg-primary);
}

.sg-meta {
    font-size: 0.75rem;
    color: var(--sg-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* --- Lightbox Styles --- */
.sg-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sg-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sg-lightbox-container {
    background: white;
    width: 100%;
    max-width: 1100px;
    height: 80vh;
    max-height: 700px;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s;
}

.sg-lightbox-overlay.active .sg-lightbox-container {
    transform: scale(1);
}

.sg-lb-video {
    flex: 2;
    background: black;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sg-lb-video iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.sg-lb-details {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e5e7eb;
    position: relative;
    min-width: 300px;
}

.sg-lb-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sg-lb-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.sg-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 4px;
    transition: color 0.2s;
}
.sg-close-btn:hover { color: #1f2937; }

.sg-close-mobile {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    background: rgba(0,0,0,0.5);
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

.sg-lb-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.sg-lb-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 20px;
    font-weight: 500;
}

.sg-lb-desc {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #4b5563;
    white-space: pre-wrap;
}

/* Responsive Lightbox */
@media (max-width: 1024px) {
    .sg-lightbox-container {
        flex-direction: column;
        height: auto;
        max-height: 90vh;
    }
    .sg-lb-video {
        width: 100%;
        aspect-ratio: 16/9;
        flex: none;
    }
    .sg-lb-details {
        flex: 1;
        overflow: hidden;
    }
    .sg-close-btn { display: none; }
    .sg-close-mobile { display: flex; }
    .sg-lb-title { font-size: 1rem; }
}