:root {
    /* Light Theme (Default) */
    --bg-color: #fefae0;
    /* Vintage Paper White */
    --text-color: #4a403a;
    /* Dark Brown/Grey */
    --card-bg: rgba(255, 255, 255, 0.7);
    --navbar-bg: #faedcd;
    /* Light Sepia */
    --primary-color: #8b5e3c;
    --primary-rgb: 139, 94, 60;
    /* Warm Brown */
    --secondary-color: #d4a373;
    --accent-color: #bc6c25;
    /* Bronze */
    --inputs-bg: #ffffff;
    --inputs-border: #ced4da;
}

[data-theme="dark"] {
    /* Dark Theme - Darker & Better Contrast */
    --bg-color: #121212;
    /* Very Dark Grey (almost black) */
    --text-color: #f0f0f0;
    /* Pure White for better readability */
    --card-bg: #1e1e1e;
    /* Solid dark card background (no transparency issues) */
    --navbar-bg: #1a1a1a;
    /* Darker Navbar */
    --primary-color: #d4a373;
    --primary-rgb: 212, 163, 115;
    /* Keep Gold/Light Brown */
    --secondary-color: #8b5e3c;
    --accent-color: #f4a261;
    --inputs-bg: #2d2d2d;
    --inputs-border: #444;
}

.navbar {
    background-color: var(--navbar-bg) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.3s ease-in-out, background-color 0.3s;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.navbar-hidden {
    transform: translateY(-100%);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s, color 0.3s;
    padding-top: 80px;
    /* Adjust based on your navbar height */
}

.navbar-brand {
    display: flex;
    align-items: center;
    position: relative;
}

.navbar-brand:hover {
    text-decoration: none;
}

.logo-container {
    position: absolute;
    top: -10px;
    /* Overhang */
    left: 0;
    width: 64px;
    height: 64px;
    z-index: 1001;
}

.logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.brand-text {
    margin-left: 55px;
    /* Space for the logo */
    font-weight: 600;
    font-size: 1.25rem;
}

/* Navbar text fix for dark mode */
[data-theme="dark"] .navbar-light .navbar-brand,
[data-theme="dark"] .navbar-light .nav-link {
    color: var(--text-color) !important;
}

/* Link Hover Effects */
a {
    text-decoration: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.nav-link:hover {
    color: var(--primary-color) !important;
    transform: translateY(-1px);
}

.card {
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: background-color 0.3s, transform 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.text-primary {
    color: var(--primary-color) !important;
}

h1,
h2,
h3,
h4,
h5 {
    color: var(--primary-color);
}

/* Form controls in dark mode */
[data-theme="dark"] .form-control {
    background-color: var(--inputs-bg);
    border-color: var(--inputs-border);
    color: var(--text-color);
}

[data-theme="dark"] .form-control:focus {
    background-color: var(--inputs-bg);
    color: var(--text-color);
}

/* Fix for muted text in dark mode */
[data-theme="dark"] .text-muted {
    color: #b0b0b0 !important;
}

/* Reel Styles */
.reel-container {
    overflow: hidden;
    position: relative;
    width: 100%;
    margin-bottom: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.reel-track {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    /* Animation logic will be handled if dynamic, for now placeholder layout */
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

.reel-track::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.reel-item {
    min-width: 300px;
    height: 450px;
    background-color: #ddd;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-weight: bold;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.reel-item img,
.reel-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.5rem;
}

.reel-item:hover {
    transform: scale(1.02);
}

.reel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    color: var(--primary-color);
    transition: all 0.2s ease;
    opacity: 0;
}

.reel-container:hover .reel-nav-btn {
    opacity: 1;
}

.reel-nav-btn:hover {
    background-color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.reel-nav-prev {
    left: 10px;
}

.reel-nav-next {
    right: 10px;
}

[data-theme="dark"] .reel-nav-btn {
    background-color: rgba(45, 45, 45, 0.8);
    color: var(--primary-color);
}

[data-theme="dark"] .reel-nav-btn:hover {
    background-color: #3d3d3d;
}

/* Dropdown Menu Styles */
.dropdown-menu {
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
}

[data-theme="dark"] .dropdown-menu {
    background-color: #2d2d2d;
    border: 1px solid #444;
}

[data-theme="dark"] .dropdown-item {
    color: #e0e0e0;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: #3d3d3d;
    color: var(--primary-color);
}

[data-theme="dark"] .dropdown-divider {
    border-top-color: #444;
}

/* Mobile Adjustments */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: var(--navbar-bg);
        border-radius: 0 0 1rem 1rem;
        padding: 1.5rem;
        margin-top: 0.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        max-height: 80vh;
        overflow-y: auto;
    }

    .navbar-nav {
        width: 100%;
        gap: 0.5rem !important;
    }

    .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
    }

    [data-theme="dark"] .nav-item {
        border-bottom-color: rgba(255, 255, 255, 0.05);
    }

    .nav-item:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .nav-link {
        padding: 0.5rem 0;
        font-size: 1.1rem;
        display: block;
        width: 100%;
    }

    .dropdown-menu {
        border: none;
        background-color: transparent;
        box-shadow: none;
        padding-left: 1rem;
        margin-top: 0;
    }

    /* Adjust credits button for mobile */
    .nav-item .btn-outline-warning {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
    }

    /* Adjust User dropdown toggle */
    .dropdown-toggle {
        width: 100%;
        justify-content: space-between;
    }
}

/* Lightbox Styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.lightbox-image {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
}

.nav-btn {
    opacity: 0.7;
    transition: opacity 0.2s;
    background: none;
    border: none;
}

.nav-btn:hover {
    opacity: 1;
}

/* Action Bar Styles */
.action-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 1050;
    transition: all 0.3s ease;
    width: 90%;
    max-width: 700px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Scrollable Action Bar on very small screens */
/* Compact Mobile Action Bar */
@media (max-width: 767.98px) {
    .action-bar {
        width: 95%;
        bottom: 20px;
        padding: 10px 15px;
        border-radius: 50px;
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
    }

    .action-bar .container {
        flex-direction: row;
        width: 100%;
        padding: 0;
        justify-content: space-between !important;
    }

    /* Hide "photos selected" text, show only count + "Sel" maybe? 
       Actually, let's just make the text smaller or hide the "photos selected" part if possible.
       For now, let's just rely on the flex layout to squish it a bit or wrapped HTML changes.
    */
    .action-bar span.fw-bold {
        font-size: 0.8rem;
        white-space: nowrap;
        margin-right: auto;
    }

    .action-bar .btn-group {
        display: flex;
        flex-direction: row;
        gap: 5px;
        width: auto;
        overflow-x: auto;
        padding-bottom: 0;
        -webkit-overflow-scrolling: touch;
        /* Smooth scrolling on iOS */
        scrollbar-width: none;
        /* Firefox */
        flex: 1;
        /* Take available space */
        min-width: 0;
        /* Allow flex item to shrink below content size if needed (for scroll) */
        align-items: center;
        justify-content: center;
    }

    /* Hide scrollbar for Chrome, Safari and Opera */
    .action-bar .btn-group::-webkit-scrollbar {
        display: none;
    }

    .action-bar .btn {
        padding: 8px 12px;
        border-radius: 50% !important;
        /* Circular buttons for icons */
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        /* Prevent shrinking */
    }

    .action-bar .btn i {
        margin: 0 !important;
        /* Remove margin from icons since text is hidden */
        font-size: 1rem;
    }

    /* Keep Delete button distinct but circular/compact */
    .action-bar .btn-group>.btn:last-child {
        margin-left: 5px;
        background-color: #dc3545 !important;
        border-color: #dc3545 !important;
        color: white !important;
        width: 40px;
        /* Force circle */
    }
}

@media (max-width: 380px) {
    .action-bar .btn {
        padding: 8px 12px;
        border-radius: 50% !important;
        /* Circular buttons for icons */
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        /* Prevent shrinking */
    }

    .action-bar .btn-group>.btn:last-child {
        margin-left: 2px;
        background-color: #dc3545 !important;
        border-color: #dc3545 !important;
        color: white !important;
        width: 32px;
        /* Force circle */
    }
}

@media (min-width: 768px) {
    .action-bar .btn {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 0.375rem 0.5rem;
        font-size: 0.85rem;
    }
}


/* Generation Card Styles */
.generation-card {
    border: 1px solid #59442f;
    border-radius: 0.50rem;
    overflow: hidden;
    transition: all 0.3s ease;
    background-color: var(--card-bg);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.generation-card:hover {
    transform: translateY(-3px);
    -webkit-box-shadow: 0px 0px 15px 3px rgba(212, 163, 115, 0.582);
    box-shadow: 0px 0px 15px 3px rgba(212, 163, 115, 0.582);
    border: 1px solid #765b40;
}

.card-img-container {
    position: relative;
    width: 100%;
    padding-top: 100%;
    /* 1:1 Aspect Ratio by default, matches most gens */
    overflow: hidden;
    background-color: #f0f0f0;
}

.card-img-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.generation-card:hover .card-img-top {
    transform: scale(1.05);
}

.source-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 2;
}

.source-pile {
    position: absolute;
    bottom: 10px;
    right: 10px;
    height: 40px;
    /* width auto to expand */
    display: flex;
    flex-direction: row-reverse;
    /* Stack right to left visually */
    align-items: center;
    z-index: 2;
    cursor: pointer;
    transition: transform 0.2s;
}

.source-pile:hover {
    transform: scale(1.05);
}

.source-pile-item {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.2);
    margin-left: -15px;
    /* Overlap */
    position: relative;
    z-index: 1;
    transition: transform 0.2s;
}

.source-pile-item:last-child {
    margin-left: 0;
}

.source-pile-item:hover {
    transform: translateY(-3px);
    z-index: 10;
}

.source-overlay:hover {
    transform: scale(1.1);
}

.status-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(5px);
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status-completed {
    background-color: rgba(25, 135, 84, 0.9);
    color: white;
}

.status-processing {
    background-color: rgba(255, 193, 7, 0.9);
    color: #000;
}

.status-failed {
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
}

.status-pending {
    background-color: rgba(13, 110, 253, 0.9);
    color: white;
}

.card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-actions {
    margin-top: auto;
    padding-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

[data-theme="dark"] .card-img-container {
    background-color: #2d2d2d;
}

[data-theme="dark"] .source-overlay {
    border-color: #444;
}

.btn-circle {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50% !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-circle i {
    font-size: 0.875rem;
}

/* Stats Panel */
.stats-panel {
    background: linear-gradient(283deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 1rem;
    padding: 3rem 1rem;
    margin-bottom: 4rem;
    box-shadow: 0 10px 30px rgba(139, 94, 60, 0.3);
}

.stats-panel h2 {
    color: white !important;
}

.stat-number {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.stat-label {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Testimonials */
.testimonial-card {
    background-color: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    height: 100%;
    position: relative;
    transition: transform 0.3s ease;
}

.testimonial-card:hover {
    transform: translateY(-3px);
}

.testimonial-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    margin-bottom: 1rem;
}

.stars {
    color: #ffc107;
    margin-bottom: 1rem;
}

/* Before/After Slider */
.comparison-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4/3;
    /* Adjust based on your example image aspect ratio */
    margin: 0 auto;
    overflow: hidden;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    user-select: none;
    -webkit-user-select: none;
}

.comparison-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* or contain, depending on images */
    pointer-events: none;
}

.comparison-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    /* Initial state */
    height: 100%;
    overflow: hidden;
    border-right: 2px solid white;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3);
}

.comparison-overlay .comparison-image {
    width: auto;
    /* width will be set by JS to match container */
    max-width: none;
    height: 100%;
    object-fit: cover;
}

/* Let's try a simpler JS-driven width approach */
.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    z-index: 10;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.slider-handle i {
    color: var(--primary-color);
}

.border-dark {
    border-color: #373737;
}

@media (min-width: 992px) {
    .row-cols-lg-5>* {
        flex: 0 0 auto;
        width: 25%;
    }
}

/* Responsive Scale Helper */
.transform-scale-105 {
    transform: none;
}

@media (min-width: 768px) {
    .transform-scale-105 {
        transform: scale(1.05);
    }
}