/* Gallery v2 Styles - Modern Pixieset-inspired Gallery */

/* Safe area and notch support for mobile devices */
:root {
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* General Layout */
.gallery-v2 {
    min-height: 100vh;
    background: #f8f9fa;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-indicator.hidden {
    display: none;
}

/* Hide header bar for gallery-v2 (Pixieset style) */
.header-bar {
    display: none;
}

/* Hide footer for gallery-v2 (Pixieset style) */
footer {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e3e3e3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ─── Invalid Token / Access Error Overlay ─────────────────────────────────── */
.gallery-access-error {
    position: fixed;
    inset: 0;
    background: var(--bg-body, #f8f9fa);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.gallery-access-error-content {
    max-width: 480px;
}

.gallery-access-error-icon {
    font-size: 4rem;
    color: var(--danger-color, #e74c3c);
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.gallery-access-error-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary, #2d3748);
    margin-bottom: 0.75rem;
}

.gallery-access-error-message {
    font-size: 1rem;
    color: var(--text-secondary, #718096);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.gallery-access-error-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    background: var(--primary-color, #4361ee);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

.gallery-access-error-btn:hover {
    opacity: 0.88;
    color: #fff;
}

/* Gallery Hero Section */
.gallery-hero {
    position: relative;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.gallery-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.gallery-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.4) 0%, 
        rgba(0, 0, 0, 0.2) 50%, 
        rgba(0, 0, 0, 0.6) 100%);
    z-index: 2;
}

.gallery-hero-content {
    position: relative;
    z-index: 3;
    color: white;
    width: 100%;
    height: 100%;
    padding: 2rem;
}

.photographer-info {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0;
    flex-wrap: nowrap;
}

.photographer-logo {
    flex-shrink: 0;
}

.photographer-logo-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.photographer-details {
    position: absolute;
    bottom: 1.5rem;
    left: 1.5rem;
    text-align: left;
}

.gallery-title {
    font-size: 3rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.gallery-subtitle {
    font-size: 1.2rem;
    margin: 0 0 1rem 0;
    opacity: 0.9;
    font-weight: 300;
}

.photographer-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    opacity: 0.8;
    margin-left: 0;
}

.gallery-stats {
    position: absolute;
    bottom: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    padding-right: 1.5rem;
}

.stats-row {
    display: flex;
    gap: 2rem;
}

.stat-item {
    text-align: center;
}

.view-gallery-btn {
    background: transparent !important;
    border: none !important;
    color: white !important;
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    box-shadow: none !important;
}

.view-gallery-btn:hover {
    background: transparent !important;
    border: none !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: none !important;
}

.view-gallery-btn i {
    animation: bounce 2s infinite;
    color: white !important;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-3px);
    }
    60% {
        transform: translateY(-1px);
    }
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Breadcrumb Container */
.breadcrumb-container {
    background: white;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: var(--safe-area-inset-top, 0);
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 2rem;
    gap: 2rem;
    padding-left: calc(2rem + var(--safe-area-inset-left, 0));
    padding-right: calc(2rem + var(--safe-area-inset-right, 0));
}

/* Breadcrumb Section */
.breadcrumb-section {
    flex: 1;
    padding: 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
}

.breadcrumb {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex: 1;
}

.breadcrumb-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    gap: 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    position: relative;
}

.breadcrumb-item:not(:last-child)::after {
    content: '/';
    margin: 0 0.75rem;
    color: #bbb;
    font-weight: 300;
}

.breadcrumb-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.breadcrumb-link:hover {
    color: #2c3e50;
    background: #f8f9fa;
}

.breadcrumb-link.active {
    color: white;
    font-weight: 500;
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.breadcrumb-link i {
    font-size: 1rem;
}

/* Mobile-friendly breadcrumb link indicator */
@media (hover: none) and (pointer: coarse) {
    .breadcrumb-link::after {
        content: '▼';
        font-size: 0.6rem;
        margin-left: 0.25rem;
        opacity: 0.6;
        display: none;
    }
    
    .breadcrumb-item:not(:last-child) .breadcrumb-link::after {
        display: inline;
    }
}

/* Controls Section */
.controls-section {
    flex: 1 1 auto;
    padding: 0;
    display: flex;
    gap: 1.2rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: center;
}

.back-home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
    height: 2rem;
}

.back-home-btn:hover {
    background: var(--primary-hover);
    transform: translateX(-2px);
    box-shadow: 0 3px 12px rgba(52, 152, 219, 0.5);
}

.back-home-btn:active {
    transform: translateX(0);
    background: #2471a3;
}

.breadcrumb-section .back-home-btn {
    width: auto;
}

.breadcrumb-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    border: none;
    background: #27ae60;
    color: white;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.3);
    height: 2rem;
    width: 2rem;
    margin-left: auto;
}

.breadcrumb-download-btn i {
    font-size: 1.1rem;
    color: white;
}

.breadcrumb-download-btn:hover {
    background: #229954;
    transform: translateY(-2px);
    box-shadow: 0 3px 12px rgba(39, 174, 96, 0.5);
}

.breadcrumb-download-btn:active {
    transform: translateY(0);
    background: #1e8449;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.78rem;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.control-label i {
    color: var(--primary-color);
    font-size: 0.9rem;
}

.view-controls, .filter-controls, .selection-controls, .metadata-controls {
    display: flex;
    gap: 0.2rem;
    flex-wrap: nowrap;
    overflow-x: visible;
}

.view-btn, .filter-btn, .selection-btn, .metadata-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid #e0e0e0;
    background: white;
    color: #2c3e50;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
    height: 2rem;
}

/* Hide text in view and selection buttons, show only icons */
.view-btn span, .selection-btn span, .metadata-toggle-btn span {
    display: none;
}

/* Show counter text on download button */
#download-selected-btn span {
    display: inline;
}

.view-btn:hover, .filter-btn:hover, .selection-btn:hover, .metadata-toggle-btn:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
    z-index: 101;
    position: relative;
}

.view-btn.active, .filter-btn.active, .metadata-toggle-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.view-btn i, .filter-btn i, .selection-btn i, .metadata-toggle-btn i {
    font-size: 0.95rem;
}

/* Count Badge Styling */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ecf0f1;
    color: #7f8c8d;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    margin-left: 0.25rem;
}

.filter-btn.active .count-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.filter-btn:hover .count-badge {
    background: rgba(52, 152, 219, 0.15);
}

/* Selection Group Styling */
.selection-group {
    grid-column: span 1;
}

.selection-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
    border-color: #e0e0e0;
}

.selection-btn:disabled:hover {
    background: #f5f5f5;
    border-color: #e0e0e0;
    transform: none;
    box-shadow: none;
}

.selection-btn:disabled i {
    opacity: 0.6;
}

/* Download Folder Button Special Styling */
#download-folder-btn {
    background: #27ae60;
    border-color: #27ae60;
    color: white;
    display: none !important;
}

#download-folder-btn:hover {
    background: #229954;
    border-color: #1e8449;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

#download-folder-btn i {
    color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .controls-section {
        grid-template-columns: 1fr;
    }
    
    .breadcrumb-section {
        padding: 0.8rem 1rem;
    }
    
    .controls-section {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .breadcrumb-container {
        position: relative;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .breadcrumb-section {
        padding: 0;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .controls-section {
        padding: 0;
        gap: 0.5rem;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    .control-group {
        flex: 1 1 auto;
        min-width: calc(50% - 0.25rem);
    }
    
    .view-controls, .filter-controls, .selection-controls, .metadata-controls {
        justify-content: space-around;
        flex-wrap: wrap;
    }
    
    .view-btn, .filter-btn, .selection-btn, .metadata-toggle-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        height: auto;
        min-height: 36px;
        flex: 1 1 auto;
    }
    
    .control-label {
        font-size: 0.65rem;
        white-space: nowrap;
    }
    
    .breadcrumb-link {
        font-size: 0.8rem;
        padding: 0.3rem 0.4rem;
    }
    
    .breadcrumb-item:not(:last-child)::after {
        margin: 0 0.3rem;
    }
    
    .back-home-btn {
        padding: 0.4rem;
        height: 36px;
        width: 36px;
        min-width: 36px;
    }
}

@media (max-width: 480px) {
    .breadcrumb-container {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .breadcrumb-section {
        padding: 0;
        gap: 0.3rem;
    }
    
    .controls-section {
        padding: 0;
        gap: 0.5rem;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .control-group {
        flex: 0 1 auto;
        min-width: auto;
        gap: 0;
    }
    
    /* Hide labels on small mobile screens to save space */
    .control-label {
        display: none;
    }
    
    .view-controls, .filter-controls, .selection-controls, .metadata-controls {
        gap: 0.25rem;
        flex-wrap: nowrap;
    }
    
    .view-btn, .filter-btn, .selection-btn, .metadata-toggle-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
        min-height: 32px;
        flex: 0 1 auto;
    }
    
    /* Make filter buttons more compact on small screens */
    .filter-btn {
        padding: 0.35rem 0.3rem;
    }
    
    .count-badge {
        padding: 0.1rem 0.3rem;
        margin-left: 0.15rem;
        min-width: 16px;
        font-size: 0.65rem;
    }
    
    .breadcrumb-list {
        flex-wrap: wrap;
        gap: 0.2rem;
    }
    
    .breadcrumb-link {
        font-size: 0.75rem;
        padding: 0.25rem 0.3rem;
    }
    
    .back-home-btn {
        padding: 0.3rem;
        height: 32px;
        width: 32px;
        min-width: 32px;
    }
}

/* Folder Dropdown - Positioned under specific breadcrumb button */
.folder-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 250px;
    max-width: 350px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: visible;
    display: none;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.15s ease;
    pointer-events: none;
}

@media (max-width: 768px) {
    .folder-dropdown-menu {
        min-width: 200px;
        max-width: 280px;
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .folder-dropdown-menu {
        min-width: 180px;
        max-width: 90vw;
        position: fixed;
        /* Positioning handled by JavaScript for better alignment */
    }
}

.folder-dropdown-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.folder-dropdown-menu::-webkit-scrollbar {
    width: 4px;
}

.folder-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 2px;
}

.folder-dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.folder-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.folder-dropdown-menu.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.folder-dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: visible;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.folder-dropdown-item:active {
    background: #e8f4f8;
}

.folder-dropdown-item:hover {
    background: #f8f9fa;
}

.folder-dropdown-item:last-child {
    border-bottom: none;
}

.folder-dropdown-item i {
    color: var(--primary-color);
    width: 16px;
    text-align: center;
    margin-right: 0.75rem;
}

.folder-dropdown-item .folder-count {
    margin-left: auto;
    background: #e9ecef;
    color: #6c757d;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.folder-dropdown-item.disabled {
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.folder-dropdown-item.disabled:hover {
    background: transparent;
}

/* Hierarchical folder items */
.folder-dropdown-item.subfolder {
    padding-left: 2.5rem;
    background: #f8f9fa;
    border-left: 3px solid var(--primary-color);
}

.folder-dropdown-item.subfolder i {
    color: #5dade2;
}

.folder-dropdown-item.current-folder {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
    font-weight: 500;
}

.folder-dropdown-item.current-folder i {
    color: #2196f3;
}

.folder-dropdown-item {
    position: relative;
}

/* Has children indicator */
.folder-dropdown-item.has-children {
    padding-right: 2rem;
}

.folder-dropdown-item.has-children::after {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.75rem;
    color: #9ca3af;
    font-size: 0.75rem;
}

/* Submenu active state - highlight parent item */
.folder-dropdown-item.submenu-active {
    background: #f0f8ff;
    border-left: 3px solid var(--primary-color);
    padding-left: 2rem;
    font-weight: 500;
}

/* Submenu styling */
.folder-submenu {
    position: fixed;
    min-width: 200px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 2000;
}

.folder-submenu {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.folder-submenu::-webkit-scrollbar {
    width: 4px;
}

.folder-submenu::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 2px;
}

.folder-submenu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.folder-submenu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.folder-submenu.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Mobile submenu positioning */
@media (hover: none) and (pointer: coarse) {
    .folder-submenu {
        min-width: 180px;
        max-height: 300px;
        max-width: 85vw;
    }
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.submenu-item:hover {
    background: #f8f9fa;
}

.submenu-item:last-child {
    border-bottom: none;
}

/* Mobile submenu item styling */
@media (hover: none) and (pointer: coarse) {
    .submenu-item {
        padding: 0.85rem 1rem;
        font-size: 0.95rem;
        min-height: 44px;
    }
    
    .submenu-item:active {
        background: #e8f4f8;
    }
}

.submenu-item i {
    color: #5dade2;
    width: 16px;
    text-align: center;
}

.folder-item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.folder-name {
    flex: 1;
    min-width: 0;
}

/* Smaller download button for dropdown menu items */
.folder-dropdown-item .folder-download-btn {
    position: static !important;
    top: auto !important;
    right: auto !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 10px !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: unset !important;
    min-height: unset !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.2s ease;
    line-height: 1;
    color: #6c757d !important;
}

.folder-dropdown-item:hover .folder-download-btn {
    opacity: 0.8 !important;
    transform: none !important;
    background: none !important;
    color: #333 !important;
}

.folder-chevron {
    color: #999;
    font-size: 0.7rem;
    margin-left: 0.3rem;
    transition: color 0.2s ease;
}

.folder-dropdown-item.has-children:hover .folder-chevron {
    color: #333;
}

.subfolder-list {
    display: none;
    background: #f9f9f9;
    border-top: 1px solid #e9ecef;
    margin: 0.3rem -1rem -0.75rem -1rem;
    padding: 0.3rem 1rem 0.75rem 2rem;
    max-height: 250px;
    overflow-y: auto;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.subfolder-list.visible {
    display: block;
}

.subfolder-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.subfolder-item:hover {
    color: #2196f3;
}

.subfolder-item i {
    font-size: 0.75rem;
    color: #999;
}

.folder-submenu {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.folder-submenu.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.folder-download-btn {
    background: none;
    border: none;
    color: #6c757d;
    padding: 0;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s ease;
    opacity: 0.7;
    font-size: 12px;
    line-height: 1;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-download-btn:hover {
    background: #28a745;
    color: white;
    opacity: 1;
    transform: scale(1.1);
}

/* Breadcrumb hover states */
.breadcrumb-item {
    position: relative;
}

.breadcrumb-item.dropdown-active {
    z-index: 1001;
}

.breadcrumb-link {
    position: relative;
    transition: background-color 0.2s ease;
}

.breadcrumb-link.dropdown-trigger {
    background: #e3f2fd;
    color: #1976d2;
}

/* Gallery Main Content */
.gallery-main {
    padding: 0.5rem 0.5rem 0 0.5rem;
    background: #f8f9fa;
}

/* Touch-friendly styles for mobile */
@media (hover: none) and (pointer: coarse) {
    .media-item:hover {
        transform: none;
    }
    
    .media-selection-checkbox {
        opacity: 0.6;
    }
    
    .media-download-btn {
        opacity: 0.6;
    }
    
    .view-btn:hover, .filter-btn:hover, .selection-btn:hover {
        transform: none;
    }
}

.gallery-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 2rem;
}

@media (max-width: 768px) {
    .gallery-container {
        padding: 0 1rem;
    }
}

@media (max-width: 480px) {
    .gallery-container {
        padding: 0 0.5rem;
    }
}

/* Media Section */
.media-section {
    width: 100%;
    display: block;
}

/* Folders Section */
.folders-section {
    margin-bottom: 3rem;
}

.folders-section.hidden {
    display: none;
}

/* Folder Navigation Bar */
.folder-navigation {
    background: white;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 2rem;
}

.folder-nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
}

.folder-nav-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: #333;
    font-weight: 600;
    font-size: 1.1rem;
}

.folder-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.folder-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    text-decoration: none;
    color: #495057;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.folder-nav-item:hover {
    background: #e9ecef;
    color: #333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.folder-nav-item i {
    font-size: 0.85rem;
    color: var(--primary-color);
}

.folder-nav-item .folder-count {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0.25rem;
}

/* Legacy folders section (now unused) */
.folders-section {
    margin-bottom: 2rem;
    display: none;
}

.folders-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.1rem;
}

.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.folder-item {
    background: white;
    border-radius: 8px;
    padding: 0;
    text-align: center;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.folder-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
}

.folder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(52, 152, 219, 0.8) 0%,
        rgba(142, 68, 173, 0.8) 100%
    );
    z-index: 2;
}

.folder-content {
    position: relative;
    z-index: 3;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.folder-item .folder-content .folder-name {
    color: white;
    font-weight: 600;
}

.folder-item .folder-content .folder-count {
    color: rgba(255, 255, 255, 0.9);
}

.folder-item .folder-content .folder-icon {
    color: white;
}

.folder-icon {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.folder-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.folder-count {
    font-size: 0.85rem;
    color: #6c757d;
}

/* Masonry Grid */
.masonry-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    column-count: var(--masonry-columns, 3);
    column-gap: 0.25rem;
    line-height: 0;
}


@media (max-width: 320px) {
    .masonry-grid {
        --masonry-columns: 1;
    }
}

@media (min-width: 321px) and (max-width: 480px) {
    .masonry-grid {
        --masonry-columns: 2;
    }
}

@media (min-width: 481px) and (max-width: 640px) {
    .masonry-grid {
        --masonry-columns: 2;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .masonry-grid {
        --masonry-columns: 3;
    }
}

@media (min-width: 769px) and (max-width: 900px) {
    .masonry-grid {
        --masonry-columns: 4;
    }
}

@media (min-width: 901px) and (max-width: 1200px) {
    .masonry-grid {
        --masonry-columns: 5;
    }
}

@media (min-width: 1201px) {
    .masonry-grid {
        --masonry-columns: 6;
    }
}

.media-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 0.25rem;
    break-inside: avoid;
    position: relative;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.media-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.media-item.selected {
    transform: scale(0.95);
    box-shadow: 0 0 0 3px var(--primary-color);
}

.media-content {
    position: relative;
    width: 100%;
}

.media-content img,
.media-content video {
    width: 100%;
    height: auto;
    display: block;
    transition: all 0.3s ease;
}

.media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 70%,
        rgba(0, 0, 0, 0.9) 100%
    );
    opacity: 1;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    padding: 0.75rem;
    padding-bottom: 0.75rem;
}

.media-item:hover .media-overlay {
    opacity: 1;
}

.media-info {
    color: white;
    font-size: 0.85rem;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.media-filename {
    font-weight: 500;
    margin-bottom: 0.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.media-meta {
    opacity: 0.8;
    font-size: 0.75rem;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Hide metadata when toggled off */
.gallery-container.hide-metadata .media-overlay {
    opacity: 0;
    pointer-events: none;
}

.gallery-container.hide-metadata .media-item:hover .media-overlay {
    opacity: 1;
    pointer-events: auto;
}

.media-type-indicator {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.gallery-container.hide-metadata .media-type-indicator {
    display: none;
}

.gallery-container.hide-metadata .media-item:hover .media-type-indicator {
    display: flex;
}

.media-selection-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
}

@media (max-width: 768px) {
    .media-selection-checkbox,
    .media-item:hover .media-selection-checkbox {
        width: 32px;
        height: 32px;
        opacity: 0 !important;
        pointer-events: none !important;
        display: none !important;
    }
    .media-item.selected .media-selection-checkbox,
    .media-item.selected:hover .media-selection-checkbox {
        opacity: 1 !important;
        pointer-events: auto !important;
        display: flex !important;
    }
}

.media-item:hover .media-selection-checkbox,
.media-item.selected .media-selection-checkbox {
    opacity: 1;
    pointer-events: auto;
}

.media-item.selected .media-selection-checkbox {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Folder Item Styles */
.media-item.folder-item {
    cursor: pointer;
    /* overflow: hidden is inherited from .media-item base rule;
       do NOT set overflow: visible — it breaks column-count height accounting on iOS Safari */
}

.media-item.folder-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(52, 152, 219, 0.2);
}

.folder-content {
    position: relative;
    width: 100%;
    background: #f0f0f0;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.folder-content .folder-thumbnail {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.folder-placeholder {
    position: absolute;
    font-size: 3rem;
    color: rgba(80, 80, 80, 0.45);
    z-index: 1;
    line-height: 1;
}

.folder-content .media-overlay {
    background: transparent;
    opacity: 1;
}

/* ─── Folder footer (below thumbnail) ─────────────────────────────── */
.folder-footer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-surface, #f8f9fa);
    border-top: 1px solid var(--border-color, rgba(0,0,0,0.08));
    font-size: 0.78rem;
    /* Explicitly reset line-height: 0 inherited from .masonry-grid */
    line-height: 1.4;
    color: var(--text-primary, #333);
    overflow: hidden;
    flex-shrink: 0;
    /* Ensure this block participates in the li height (keeps it inside overflow:hidden li) */
    position: relative;
    z-index: 1;
}

.folder-footer i {
    flex-shrink: 0;
    font-size: 0.85rem;
    line-height: 1;
    color: var(--primary-color, #4361ee);
    opacity: 0.85;
}

.folder-footer-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    font-weight: 500;
    line-height: 1.4;
    font-size: 0.78rem;
}

/* Shrink footer slightly on small screens */
@media (max-width: 480px) {
    .folder-footer {
        padding: 0.3rem 0.5rem;
        font-size: 0.72rem;
        gap: 0.3rem;
    }
}

.folder-badge {
    display: none; /* replaced by .folder-footer */
}

.media-item.folder-item:hover .media-overlay {
    opacity: 1;
}

.media-item.folder-item .media-selection-checkbox {
    display: none;
}

.media-item.folder-item .folder-download-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    color: white !important;
    border: none;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    opacity: 1 !important;
    pointer-events: auto;
    box-shadow: none !important;
    min-width: 44px;
    min-height: 44px;
}

.media-item.folder-item .folder-delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 3.5rem;
    background: transparent;
    color: white !important;
    border: none;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    opacity: 1 !important;
    pointer-events: auto;
    box-shadow: none !important;
    min-width: 44px;
    min-height: 44px;
}

.media-item.folder-item .folder-download-btn i {
    color: white !important;
}

.media-item.folder-item .folder-delete-btn i {
    color: white !important;
}

.media-item.folder-item .folder-download-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    transform: scale(1.2) translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.media-item.folder-item .folder-delete-btn:hover {
    background: rgba(220, 53, 69, 0.7) !important;
    transform: scale(1.2) translateY(-2px);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3) !important;
    color: white !important;
}

.media-item.folder-item .folder-download-btn:hover i {
    color: white !important;
}

.media-item.folder-item .folder-delete-btn:hover i {
    color: white !important;
}

.media-item.folder-item .folder-download-btn:active {
    transform: scale(1.1) translateY(0);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.15) !important;
}

.media-item.folder-item .folder-delete-btn:active {
    transform: scale(1.1) translateY(0);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2) !important;
}

/* Media download button (for images and videos) */
.media-download-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    color: white !important;
    border: none;
    border-radius: 8px;
    padding: 0;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    box-shadow: none !important;
    flex-shrink: 0;
    touch-action: manipulation;
    min-width: 48px;
    min-height: 48px;
}

@media (max-width: 768px) {
    .media-download-btn,
    .media-item:hover .media-download-btn {
        width: 48px;
        height: 48px;
        opacity: 0 !important;
        pointer-events: none !important;
        font-size: 1.1rem;
        display: none !important;
    }
    .media-item.folder-item .folder-download-btn,
    .media-item.folder-item:hover .folder-download-btn {
        opacity: 0 !important;
        pointer-events: none !important;
        display: none !important;
    }
}

.media-download-btn i {
    color: white !important;
}

.media-item:hover .media-download-btn {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Show download button permanently when metadata is visible */
.gallery-container:not(.hide-metadata) .media-download-btn {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.media-download-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    transform: scale(1.2) translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.media-download-btn:hover i {
    color: white !important;
}

.media-download-btn:active {
    transform: scale(1.1) translateY(0);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.15) !important;
}

/* Grid View Alternative */
.gallery-container.grid-view .masonry-grid {
    column-count: unset !important;
    columns: unset !important;
    display: grid !important;
    grid-template-columns: repeat(var(--grid-columns, 6), 1fr) !important;
    gap: 0.25rem !important;
    line-height: auto !important;
}

.gallery-container.grid-view .media-item {
    margin-bottom: 0;
    break-inside: auto !important;
    width: auto !important;
    display: block !important;
}

.gallery-container.grid-view .media-content {
    aspect-ratio: 1;
    overflow: hidden;
}

.gallery-container.grid-view .media-content img,
.gallery-container.grid-view .media-content video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Grid View Responsive */
@media (max-width: 320px) {
    .gallery-container.grid-view .masonry-grid {
        --grid-columns: 1;
    }
}

@media (min-width: 321px) and (max-width: 480px) {
    .gallery-container.grid-view .masonry-grid {
        --grid-columns: 2;
    }
}

@media (min-width: 481px) and (max-width: 640px) {
    .gallery-container.grid-view .masonry-grid {
        --grid-columns: 2;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .gallery-container.grid-view .masonry-grid {
        --grid-columns: 3;
    }
}

@media (min-width: 769px) and (max-width: 900px) {
    .gallery-container.grid-view .masonry-grid {
        --grid-columns: 4;
    }
}

@media (min-width: 901px) and (max-width: 1200px) {
    .gallery-container.grid-view .masonry-grid {
        --grid-columns: 5;
    }
}

@media (min-width: 1201px) {
    .gallery-container.grid-view .masonry-grid {
        --grid-columns: 6;
    }
}

/* List View Alternative */
.gallery-container.list-view .masonry-grid {
    column-count: unset;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gallery-container.list-view .media-item {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    padding: 1rem;
}

.gallery-container.list-view .media-content {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    margin-right: 1rem;
}

.gallery-container.list-view .media-content img,
.gallery-container.list-view .media-content video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #6c757d;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Load More */
.load-more-container {
    text-align: center;
    padding: 2rem;
}

.load-more-container.hidden {
    display: none;
}

.load-more-btn {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.load-more-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: none;
    overflow: hidden;
}

.lightbox.active {
    display: flex;
    flex-direction: column;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
    z-index: 1;
}

.lightbox-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 2;
}

.lightbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    z-index: 10;
}

@media (max-width: 768px) {
    .lightbox-header {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .lightbox-header {
        padding: 0.5rem 0.75rem;
    }
}

.lightbox-info h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
}

.lightbox-info p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

@media (max-width: 768px) {
    .lightbox-info h4 {
        font-size: 0.95rem;
        margin-bottom: 0.15rem;
    }
    
    .lightbox-info p {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .lightbox-info h4 {
        font-size: 0.85rem;
    }
    
    .lightbox-info p {
        font-size: 0.7rem;
    }
}

.lightbox-actions {
    display: flex;
    gap: 0.5rem;
}

.lightbox-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
}

@media (max-width: 480px) {
    .lightbox-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100% !important;
    max-width: none !important;
    min-height: 0;
    overflow: hidden;
}

.lightbox-media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
    box-sizing: border-box;
}

.lightbox-media img,
.lightbox-media video {
    max-width: calc(100vw - 4rem);
    max-height: calc(100vh - 12rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
    display: block;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .lightbox-media img,
    .lightbox-media video {
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 10rem);
    }
}

@media (max-width: 480px) {
    .lightbox-media img,
    .lightbox-media video {
        max-width: calc(100vw - 1rem);
        max-height: calc(100vh - 8rem);
        border-radius: 4px;
    }
}

.lightbox-media img.loading {
    opacity: 0;
}

.lightbox-media img.loaded {
    opacity: 1;
}

.lightbox-media video.hidden {
    display: none;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 15;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

@media (max-width: 768px) {
    .lightbox-nav {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    
    .lightbox-prev {
        left: 0.75rem;
    }
    
    .lightbox-next {
        right: 0.75rem;
    }
}

@media (max-width: 480px) {
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
    
    .lightbox-prev {
        left: 0.5rem;
    }
    
    .lightbox-next {
        right: 0.5rem;
    }
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lightbox-nav:disabled:hover {
    transform: translateY(-50%);
}

.lightbox-thumbnails {
    background: rgba(0, 0, 0, 0.9);
    padding: 1rem 2rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    justify-content: center;
    min-height: 80px;
    flex-shrink: 0;
    z-index: 10;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .lightbox-thumbnails {
        padding: 0.75rem 1rem;
        min-height: 70px;
        gap: 0.4rem;
    }
}

@media (max-width: 480px) {
    .lightbox-thumbnails {
        padding: 0.5rem 0.75rem;
        min-height: 60px;
        gap: 0.3rem;
    }
}

.lightbox-thumbnails {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.lightbox-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.lightbox-thumbnails::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 2px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-thumb {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
    touch-action: manipulation;
}

@media (max-width: 768px) {
    .lightbox-thumb {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .lightbox-thumb {
        width: 44px;
        height: 44px;
    }
}

.lightbox-thumb.active {
    border-color: var(--primary-color);
}

.lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .masonry-grid {
        column-count: 5;
    }
    
    .gallery-hero {
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
    }
    
    .gallery-title {
        font-size: 2.5rem;
    }
    
    .photographer-info {
        flex-direction: column;
        text-align: center;
    }
    
    .photographer-details {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .gallery-hero {
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        padding: 1rem;
    }
    
    .photographer-info {
        gap: 0.5rem;
    }
    
    .photographer-logo-img {
        width: 50px;
        height: 50px;
        border-width: 2px;
    }
    
    .photographer-name {
        font-size: 0.85rem;
    }
    
    .photographer-details {
        bottom: 0.5rem;
        left: 0.5rem;
    }
    
    .gallery-title {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .gallery-subtitle {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .gallery-stats {
        bottom: 0.5rem;
        right: 0.5rem;
        gap: 0.25rem;
        padding-right: 0.5rem;
    }
    
    .stats-row {
        gap: 1.5rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .view-gallery-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .gallery-hero {
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        padding: 0.75rem;
    }
    
    .photographer-logo-img {
        width: 40px;
        height: 40px;
        border-width: 2px;
    }
    
    .photographer-name {
        font-size: 0.75rem;
    }
    
    .gallery-title {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }
    
    .gallery-subtitle {
        font-size: 0.8rem;
        margin-bottom: 0.3rem;
    }
    
    .gallery-stats {
        gap: 0.15rem;
        padding-right: 0.3rem;
    }
    
    .stats-row {
        gap: 1rem;
    }
    
    .stat-number {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .view-gallery-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
}

/* 900px breakpoint consolidated above */

/* 768px breakpoint consolidated above */

/* 480px breakpoint consolidated above */

/* Mobile Typography Adjustments for Thumbnails */
@media (max-width: 768px) {
    .media-type-indicator span {
        display: none;
    }
    .media-type-indicator {
        padding: 0.25rem 0.35rem;
        bottom: 0.3rem;
        right: 0.3rem;
        gap: 0;
    }
    .media-overlay {
        padding: 0.5rem;
    }
    .media-info {
        padding-right: 1.8rem;
    }
    .media-filename {
        font-size: 0.8rem;
        margin-bottom: 0.15rem;
        line-height: 1.2;
    }
    .media-meta {
        font-size: 0.65rem;
        line-height: 1.2;
        opacity: 0.9;
    }
}

.column-select {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.5rem;
    border: 1px solid #e0e0e0;
    background: white;
    color: #2c3e50;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 2rem;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%232c3e50%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.65rem auto;
    padding-right: 1.5rem;
    min-width: 60px;
}

.column-select:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%233498db%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.column-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Mobile styles for column select */
@media (max-width: 768px) {
    .column-select {
        height: auto;
        min-height: 36px;
        padding: 0.4rem 0.6rem;
        padding-right: 1.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .column-select {
        padding: 0.35rem 0.5rem;
        padding-right: 1.5rem;
        font-size: 0.7rem;
        min-height: 32px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Admin Gallery Actions Dropdown (admin-gallery-actions.js)
   Only injected for admin / photographer roles — never in the DOM for guests.
───────────────────────────────────────────────────────────────────────────── */

/* Floating wrapper — fixed bottom-right, above lightbox */
.aga-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Toggle button */
.aga-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    background: rgba(20, 20, 30, 0.88);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
    user-select: none;
    white-space: nowrap;
}

.aga-btn:hover {
    background: rgba(40, 40, 60, 0.95);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.55);
    transform: translateY(-1px);
}

.aga-btn:focus-visible {
    outline: 2px solid #6c8aff;
    outline-offset: 2px;
}

.aga-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.aga-btn-icon {
    font-size: 0.9rem;
    color: #a0afd4;
}

.aga-chevron {
    font-size: 0.65rem;
    color: #8899b8;
    transition: transform 0.2s;
}

.aga-btn[aria-expanded="true"] .aga-chevron {
    transform: rotate(180deg);
}

/* Dropdown menu */
.aga-menu {
    list-style: none;
    margin: 0 0 6px 0;
    padding: 6px 0;
    background: rgba(18, 18, 28, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    min-width: 220px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
    /* Entrance animation */
    animation: agaMenuIn 0.15s ease forwards;
}

@keyframes agaMenuIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)  scale(1); }
}

/* Menu item */
.aga-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1rem;
    color: #d4dff8;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.aga-item:hover,
.aga-item:focus {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    outline: none;
}

.aga-item:focus-visible {
    outline: 2px solid #6c8aff;
    outline-offset: -2px;
}

.aga-item-icon {
    width: 1rem;
    text-align: center;
    color: #8fa2d1;
    flex-shrink: 0;
}

/* Separator */
.aga-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 5px 10px;
}

/* Toast notification */
.aga-toast {
    position: fixed;
    bottom: 88px; /* above the dropdown button */
    right: 24px;
    z-index: 10001;
    max-width: min(480px, calc(100vw - 48px));
    padding: 0.75rem 1.1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: #fff;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    word-break: break-word;
}

.aga-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.aga-toast--success {
    background: rgba(34, 120, 80, 0.92);
    border: 1px solid rgba(80, 200, 130, 0.3);
}

.aga-toast--error {
    background: rgba(160, 40, 40, 0.92);
    border: 1px solid rgba(220, 100, 100, 0.3);
}

/* ─── Results dialog (native <dialog>) ───────────────────────────────────── */
dialog.aga-dialog {
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface, #fff);
    margin: auto;
}

dialog.aga-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.aga-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.aga-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.aga-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.aga-modal-close:hover {
    background: var(--bg-hover, #f1f5f9);
}

.aga-modal-summary {
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
    background: var(--bg-muted, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.aga-modal-errors {
    color: var(--danger-color, #e74c3c);
    font-weight: 600;
}

.aga-modal-body {
    overflow-x: auto;
    max-height: 60vh;
    overflow-y: auto;
}

.aga-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.aga-th {
    position: sticky;
    top: 0;
    background: var(--bg-muted, #f8fafc);
    padding: 0.55rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    white-space: nowrap;
}

.aga-th--num { text-align: right; }

.aga-td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-primary, #1e293b);
    word-break: break-all;
}

.aga-td--num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.aga-td--err {
    color: var(--danger-color, #e74c3c);
    font-weight: 600;
}

.aga-trow:last-child .aga-td { border-bottom: none; }
.aga-trow:hover .aga-td { background: var(--bg-hover, #f1f5f9); }
.aga-trow--error .aga-td--folder { color: var(--danger-color, #e74c3c); }

.aga-dialog-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: flex-end;
    background: var(--bg-surface, #fff);
}

.aga-dialog-close-btn {
    padding: 0.45rem 1.1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-muted, #f8fafc);
    color: var(--text-primary, #1e293b);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

.aga-dialog-close-btn:hover {
    background: var(--bg-hover, #f1f5f9);
}

/* Mobile: full-width at the bottom */
@media (max-width: 480px) {
    .aga-wrapper {
        right: 12px;
        bottom: 16px;
    }

    .aga-menu {
        min-width: calc(100vw - 24px);
        right: 0;
        position: fixed;
        bottom: 68px;
    }

    .aga-toast {
        right: 12px;
        bottom: 80px;
        max-width: calc(100vw - 24px);
    }
}

/* ─── Picker Mode: hide hero + breadcrumb ─────────────────────────────────────── */
body.gallery-picker-mode .gallery-hero,
body.gallery-picker-mode .breadcrumb-container {
  display: none !important;
}

/* ─── Event Picker Overlay ──────────────────────────────────────────────────────── */
.event-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.event-picker-inner {
    background: var(--bg-surface, #fff);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 860px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.event-picker-inner h2 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    color: var(--text-primary, #1a1a1a);
}

.event-picker-inner > p {
    color: var(--text-secondary, #666);
    margin: 0 0 1.5rem;
}

.event-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.event-picker-card {
    display: block;
    padding: 1.2rem;
    background: var(--bg-surface, #fff);
    border: 1.5px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.event-picker-card:hover {
    border-color: var(--primary-color, #4361ee);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.event-picker-card-type {
    font-size: 0.78rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.event-picker-card h3 {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    color: var(--text-primary, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-picker-card-meta {
    font-size: 0.82rem;
    color: var(--text-secondary, #888);
}

.event-picker-all {
    display: block;
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-secondary, #888);
    text-decoration: none;
    padding: 0.4rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.event-picker-all:hover {
    background: var(--bg-hover, #f3f4f6);
    color: var(--primary-color, #4361ee);
}

@media (max-width: 600px) {
    .event-picker-inner {
        padding: 1.5rem;
    }
    .event-picker-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── No-Events State ───────────────────────────────────────────────────────────── */
.no-events-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    text-align: center;
    color: var(--text-secondary, #888);
    gap: 1rem;
}

.no-events-state i {
    color: var(--border-color, #ccc);
}

.no-events-state h3 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text-primary, #333);
}

.no-events-state p {
    margin: 0;
    font-size: 0.95rem;
}

/* ─── Event Switcher (action bar) ───────────────────────────────────────────────── */
.event-switcher {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.event-switcher .control-label {
    color: var(--text-secondary, #888);
    font-size: 0.85rem;
    margin-bottom: 0;
}

.event-switcher-select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.88rem;
    background: var(--bg-surface, #fff);
    color: var(--text-primary, #333);
    cursor: pointer;
    max-width: 200px;
    min-width: 120px;
}

.event-switcher-select:hover {
    border-color: var(--primary-color, #4361ee);
}

@media (max-width: 480px) {
    .event-switcher-select {
        max-width: 130px;
        min-width: 90px;
        font-size: 0.78rem;
    }
}
