/* 
   Image Gallery Styles
   Professional, Responsive, Premium Design
*/

:root {
    /* Fonts */
    --font-title: 'Gabriela', serif;
    --font-body: 'Lato', sans-serif;

    --thumb-size: 150px;
    --gap-size: 20px;
    --border-radius: calc(var(--thumb-size) * 0.06);
    /* Dynamic rounding: 6% of size */
    --transition-speed: 0.3s;

    /* Dynamic Font Sizes for Folders based on Thumb Size */
    --folder-icon-size: calc(var(--thumb-size) * 0.4);
    --folder-text-size: calc(var(--thumb-size) * 0.15);

    /* Default Theme: Dark Mode Sky Blue */
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-color: #38bdf8;
    /* Sky Blue */
    --accent-hover: #0ea5e9;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --lightbox-bg: rgba(15, 23, 42, 0.95);

    /* Scrollbar */
    --scrollbar-track: #0f172a;
    --scrollbar-thumb: #38bdf8;
}

/* Theme Classes will be applied to body */

/* Dark Theme 2: Deep Purple */
body.theme-1 {
    --bg-color: #1a0b2e;
    --card-bg: #2d1b4e;
    --text-color: #f3e8ff;
    --text-muted: #d8b4fe;
    --accent-color: #c084fc;
    --accent-hover: #a855f7;
    --border-color: #4c1d95;
    --scrollbar-thumb: #c084fc;
}

/* Dark Theme 3: Midnight Teal */
body.theme-2 {
    --bg-color: #042f2e;
    --card-bg: #115e59;
    --text-color: #ccfbf1;
    --text-muted: #99f6e4;
    --accent-color: #2dd4bf;
    --accent-hover: #14b8a6;
    --border-color: #134e4a;
    --scrollbar-thumb: #2dd4bf;
}

/* Dark Theme 4: Charcoal Red */
body.theme-3 {
    --bg-color: #18181b;
    --card-bg: #27272a;
    --text-color: #ffe4e6;
    --text-muted: #fda4af;
    --accent-color: #f43f5e;
    --accent-hover: #e11d48;
    --border-color: #3f3f46;
    --scrollbar-thumb: #f43f5e;
}

/* Light Theme 1: Clean White/Blue */
body.theme-4 {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #334155;
    --text-muted: #64748b;
    --accent-color: #0284c7;
    --accent-hover: #0369a1;
    --border-color: #cbd5e1;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
    --lightbox-bg: rgba(255, 255, 255, 0.95);
    --scrollbar-track: #f1f5f9;
    --scrollbar-thumb: #0284c7;
}

/* Light Theme 2: Warm Beige */
body.theme-5 {
    --bg-color: #fffbeb;
    --card-bg: #ffffff;
    --text-color: #78350f;
    --text-muted: #92400e;
    --accent-color: #d97706;
    --accent-hover: #b45309;
    --border-color: #fde68a;
    --scrollbar-thumb: #d97706;
}

/* Light Theme 3: Mint Fresh */
body.theme-6 {
    --bg-color: #f0fdf4;
    --card-bg: #ffffff;
    --text-color: #14532d;
    --text-muted: #166534;
    --accent-color: #16a34a;
    --accent-hover: #15803d;
    --border-color: #bbf7d0;
    --scrollbar-thumb: #16a34a;
}

/* Light Theme 4: Lavender Mist */
body.theme-7 {
    --bg-color: #faf5ff;
    --card-bg: #ffffff;
    --text-color: #581c87;
    --text-muted: #6b21a8;
    --accent-color: #9333ea;
    --accent-hover: #7e22ce;
    --border-color: #e9d5ff;
    --border-color: #e9d5ff;
    --scrollbar-thumb: #9333ea;
}

/* Transparent Theme: For Iframes */
body.theme-transparent {
    --bg-color: transparent;
    --card-bg: rgba(30, 41, 59, 0.7);
    /* Semi-transparent card */
    --text-color: #ffffff;
    --text-muted: #e2e8f0;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --border-color: rgba(255, 255, 255, 0.2);
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(255, 255, 255, 0.5);
    background-color: transparent !important;
    /* Force override */
}



/* Base Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    transition: background-color 0.5s ease, color 0.5s ease;
    overflow-y: scroll;
    /* Always show vertical scroll */
    /* Always show vertical scroll */
    overflow-x: hidden;
}

/* Special Case: Allow transparent root if theme-transparent is applied */
html.transparent-mode {
    background-color: transparent;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

/* Title Section */
.title-section {
    padding: 1rem 1rem 0.5rem 1rem;
    text-align: center;
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.banner-img {
    width: 98%;
    max-width: 980px;
    height: auto;
    border-radius: 10px;
    margin-bottom: 10px;
}

.title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.main-title {
    font-family: var(--font-title);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.description-text {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Controls */
.controls-container {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    align-items: center;
    justify-content: center;
}

.control-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    min-width: 44px;
    min-height: 44px;
}

.control-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(2px);
}

/* Gallery Grid */
.gallery-container {
    padding: 0 var(--gap-size) var(--gap-size) var(--gap-size);
    max-width: 100%;
    margin: 0 auto;
}

.breadcrumb {
    margin-bottom: 20px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-muted);
}

.breadcrumb-item {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 600;
}

.breadcrumb-item:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-muted);
    opacity: 0.6;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--thumb-size), 1fr));
    gap: var(--gap-size);
    justify-content: center;
}

.gallery-item {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    overflow: visible;
    /* Changed to visible to show image shadows if needed */
    position: relative;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1;
}

.gallery-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-color);
    z-index: 10;
}

.gallery-thumb {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background-color: transparent;
    border-radius: var(--border-radius);
    transition: filter 0.3s, transform 0.3s;
}

/* Tooltip */
.gallery-item::after {
    content: attr(data-filename);
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.8rem;
    padding: 4px;
    text-align: center;
    opacity: 0;
    transform: translateY(100%);
    transition: all 0.3s;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-item:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* Scalable Folder Items */
.folder-item {
    flex-direction: column !important;
}

.folder-item .folder-icon {
    font-size: var(--folder-icon-size);
    line-height: 1;
    margin-bottom: 5px;
}

.folder-item .folder-name {
    font-size: var(--folder-text-size);
    /* min font size so it's readable */
    font-size: max(14px, var(--folder-text-size));
    text-align: center;
    word-break: break-all;
    line-height: 1.2;
}

/* Lightbox/Full View */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--lightbox-bg);
    display: flex;
    flex-direction: column;
    /* Column for caption */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-img {
    max-width: 95vw;
    max-height: 85vh;
    /* Reduced height to make room for caption */
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    object-fit: contain;
}

.lightbox-caption {
    margin-top: 15px;
    color: var(--text-color);
    font-size: 1.2rem;
    font-family: var(--font-body);
    text-align: center;
    max-width: 90%;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

/* Lightbox Navigation */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 3rem;
    padding: 20px 10px;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1010;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

@media (max-width: 768px) {
    .lightbox-nav {
        font-size: 2rem;
        padding: 15px 5px;
        background: rgba(0, 0, 0, 0.3);
    }

    .lightbox-nav.prev {
        left: 5px;
    }

    .lightbox-nav.next {
        right: 5px;
    }
}

/* Loading/Processing Screen Styles */
.processing-container {
    max-width: 800px;
    margin: 2rem auto;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.processing-header {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--accent-color);
    font-family: var(--font-title);
    font-size: 1.8rem;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

.file-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    align-items: center;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
}

.file-status {
    font-weight: bold;
}

.status-waiting {
    color: var(--text-muted);
}

.status-processing {
    color: var(--accent-color);
    animation: pulse 1.5s infinite;
}

.status-finished {
    color: #10b981;
}

/* Green */
.status-error {
    color: #ef4444;
}

/* Red */

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item {
    animation: fadeIn 0.5s ease backwards;
}

/* Helper Class for staggered animation handled in JS or using nth-child */
.gallery-item:nth-child(1) {
    animation-delay: 0.05s;
}

.gallery-item:nth-child(2) {
    animation-delay: 0.1s;
}

.gallery-item:nth-child(3) {
    animation-delay: 0.15s;
}

.gallery-item:nth-child(4) {
    animation-delay: 0.2s;
}

.gallery-item:nth-child(5) {
    animation-delay: 0.25s;
}

/* ...and so on */

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .main-title {
        font-size: 1.8rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .title-section {
        padding: 1rem 0.5rem;
    }

    .file-row {
        grid-template-columns: 1fr;
        gap: 5px;
        text-align: center;
    }
}

/* Invisible Container Mode: Show only image, no box */
body.no-container .gallery-item {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 10px !important;
    aspect-ratio: 1 / 1 !important;
    overflow: visible !important;
}

body.no-container .gallery-item:hover {
    transform: scale(1.08);
    box-shadow: none !important;
}

body.no-container .gallery-thumb {
    border-radius: var(--border-radius) !important;
    background-color: transparent !important;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    /* Premium shadow on the image itself */
    max-height: 100%;
    max-width: 100%;
    width: auto !important;
    height: auto !important;
}