/* Z-Image Generator - Modern Responsive UI */
/* Color Scheme from dark.html / light.html templates */

:root {
    /* Colors from dark.html */
    --primary: #0faeae;
    --secondary: #ba0834;
    --tertiary: #1243a5;
    --gr-shift: #af0e79;
    --new-cyan: #51ecd2;
    --success: #0cc039;

    --text-primary: #e0f0f8;
    --text-secondary: #a8c8e0;

    --layer-1: rgba(11, 22, 35, 0.118);
    --layer-2: rgba(11, 22, 35, 0.236);
    --layer-3: rgba(11, 22, 35, 0.382);
    --layer-4: rgba(11, 22, 35, 0.618);
    --layer-5: rgba(11, 22, 35, 0.764);
    
    /* Legacy variable mapping for compatibility */
    --primary-dark: var(--primary);
    --primary-mid: var(--primary);
    --primary-light: var(--new-cyan);
    
    --bg-dark-90: var(--layer-5);
    --bg-dark-70: var(--layer-4);
    --bg-dark-50: var(--layer-3);
    --bg-dark-30: var(--layer-2);
    --bg-dark-15: var(--layer-1);
    --bg-dark-10: rgba(11, 22, 35, 0.08);
    --bg-dark-5: rgba(11, 22, 35, 0.04);
    
    --bg-mid-90: rgba(81, 236, 210, 0.15);
    --bg-mid-70: rgba(81, 236, 210, 0.12);
    --bg-mid-50: rgba(81, 236, 210, 0.08);
    --bg-mid-30: rgba(81, 236, 210, 0.06);
    --bg-mid-20: rgba(81, 236, 210, 0.04);
    --bg-mid-15: rgba(81, 236, 210, 0.03);
    --bg-mid-10: rgba(81, 236, 210, 0.02);
    --bg-mid-5: rgba(81, 236, 210, 0.01);
    
    --bg-light-90: rgba(81, 236, 210, 0.2);
    --bg-light-70: rgba(81, 236, 210, 0.15);
    --bg-light-50: rgba(81, 236, 210, 0.1);
    --bg-light-30: rgba(81, 236, 210, 0.07);
    --bg-light-15: rgba(81, 236, 210, 0.04);
    --bg-light-10: rgba(81, 236, 210, 0.02);
    --bg-light-5: rgba(81, 236, 210, 0.01);
    
    --text-light: var(--text-primary);
    --text-dark: #0a1f2c;
    --text-muted: var(--text-secondary);
    
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--new-cyan) 100%);
    --gradient-dark: linear-gradient(135deg, var(--primary) 0%, var(--tertiary) 100%);
    --gradient-bg: linear-gradient(135deg, #02050f 0%, #0a1a2f 100%);
    
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--gradient-bg);
    color: var(--text-light);
    line-height: 1.6;
    overflow-x: hidden;
    padding-top: 20px;
}

/* Navigation Bar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--layer-4);
    backdrop-filter: blur(32px);
    border-bottom: 1px solid rgba(81, 236, 210, 0.09);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    z-index: 1000;
}

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

.navbar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.navbar-logo img {
    transition: transform 0.2s ease;
}

.navbar-logo:hover img {
    transform: scale(1.1);
}

.navbar-brand-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 8px;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-link svg {
    flex-shrink: 0;
}

.nav-link:hover {
    color: var(--text-light);
    background: rgba(51, 177, 196, 0.1);
    border-color: rgba(51, 177, 196, 0.3);
}

.nav-link.active {
    color: var(--text-light);
    background: rgba(51, 177, 196, 0.15);
    border-color: rgba(51, 177, 196, 0.5);
}

/* Adjust app container for fixed navbar */
.app-container {
    margin-top: 60px;
    min-height: calc(100vh - 60px);
    padding: var(--spacing-md);
    width: 100%;
    max-width: 100%;
}

/* Mobile navbar */
@media (max-width: 640px) {
    .navbar {
        padding: 0 var(--spacing-md);
    }

    .nav-link span {
        display: none;
    }

    .nav-link {
        padding: var(--spacing-xs);
    }
    
    .gallery-container {
        flex-wrap: nowrap;
    }
}

/* Header */
.app-header {
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-md);
    margin: 0 auto var(--spacing-md);
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.app-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), var(--new-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--spacing-xs);
}

.app-subtitle {
    color: var(--text-muted);
    font-size: clamp(0.85rem, 2vw, 1rem);
}

/* Main content area */
.app-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    align-content: start;
}

/* Cards - glassmorphism effect */
.card {
    background: var(--bg-mid-15);
    backdrop-filter: blur(10px);
    border: 1px solid var(--bg-light-30);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
}

.card:hover {
    background: var(--bg-mid-20);
    border-color: var(--bg-light-50);
    box-shadow: 0 8px 32px rgba(58, 110, 166, 0.2);
}

/* Rate limit info */
.rate-limit-card {
    background: var(--bg-dark-15);
    border: 1px solid var(--bg-mid-30);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: var(--spacing-sm);
    font-size: 0.9rem;
}

.rate-limit-icon {
    font-size: 1.2rem;
}

.rate-limit-text {
    font-weight: 500;
}

.rate-limit-remaining {
    color: var(--primary-light);
    font-weight: 700;
}

/* Notification */
#notification {
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

#notification a {
    color: #3b82f6;
    text-decoration: none;
}

#notification a:hover {
    text-decoration: underline;
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1b263b;
    border-top: 1px solid #3d5a80;
    padding: var(--spacing-md);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

[data-theme="light"] .cookie-banner {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    color: #212529;
}

[data-theme="light"] .cookie-banner a {
    color: #0d6efd;
}

[data-theme="light"] .cookie-banner .btn-secondary {
    background: #e9ecef;
    border: 1px solid #ced4da;
    color: #495057;
}

[data-theme="light"] .cookie-banner .btn-secondary:hover {
    background: #dee2e6;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.cookie-content {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: var(--spacing-md);
    max-width: 1200px;
    margin: 0 auto;
    font-size: 0.875rem;
}

.cookie-content a {
    color: var(--accent);
    text-decoration: underline;
}

.cookie-buttons {
    display: flex;
    gap: var(--spacing-sm);
}

.cookie-content .btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .cookie-content {
        flex-direction: column;
        text-align: center;
    }
    
    .cookie-buttons {
        flex-direction: row;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-dark-90);
    color: var(--text-light);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--primary-light);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Form elements */
.input-group {
    margin-bottom: var(--spacing-md);
}

.input-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Prompt textarea */
#prompt {
    width: 100%;
    min-height: 120px;
    padding: var(--spacing-md);
    padding-right: 50px;
    background: var(--bg-dark-10);
    border: 2px solid var(--bg-mid-30);
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-size: 1rem;
    resize: vertical;
    transition: all 0.3s ease;
    font-family: inherit;
}

#prompt::placeholder {
    color: var(--text-muted);
}

#prompt:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--bg-dark-15);
    box-shadow: 0 0 20px rgba(58, 146, 166, 0.2);
}

/* Prompt textarea with copy button */
.prompt-textarea-wrapper {
    position: relative;
}

.prompt-copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    padding: 8px;
    background: var(--bg-mid-30);
    border: 1px solid rgba(51, 177, 196, 0.4);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0.7;
}

.prompt-copy-btn:hover {
    background: var(--primary-light);
    color: var(--text-dark);
    opacity: 1;
}

.prompt-copy-btn:active {
    transform: scale(0.95);
}

/* Controls row */
.controls-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

@media (min-width: 640px) {
    .controls-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* Select and input styling */
select, input[type="number"] {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-dark-10);
    border: 2px solid var(--bg-mid-30);
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

select:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--bg-dark-15);
}

select option {
    background: var(--primary-dark);
    color: var(--text-light);
}

/* Seed control with button inline */
.seed-control-wrapper {
    display: flex;
    gap: var(--spacing-sm);
}

#seed {
    flex: 1;
}

/* Buttons */
.btn {
    position: relative;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--primary);
    border: 1px solid var(--new-cyan);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-md);
    padding: 2px;
    background: linear-gradient(90deg, transparent, #ffffff, transparent);
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover::before {
    opacity: 1;
    animation: circulate 2s linear infinite;
}

@keyframes circulate {
    0% { background: linear-gradient(0deg, transparent, #ffffff, transparent); }
    25% { background: linear-gradient(90deg, transparent, #ffffff, transparent); }
    50% { background: linear-gradient(180deg, transparent, #ffffff, transparent); }
    75% { background: linear-gradient(270deg, transparent, #ffffff, transparent); }
    100% { background: linear-gradient(360deg, transparent, #ffffff, transparent); }
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(15, 174, 174, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-mid-30);
    border: 1px solid rgba(51, 177, 196, 0.4);
    font-size: 0.85rem;
    padding: var(--spacing-xs) var(--spacing-sm);
}

.btn-secondary:hover {
    background: var(--bg-mid-50);
}

/* Generate button - prominent */
.btn-generate {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.1rem;
    margin: var(--spacing-md) 0;
}

/* Loading state */
#loading {
    display: none;
    text-align: center;
    padding: var(--spacing-xl);
}

#loading.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#queue-status {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: var(--spacing-md);
}

/* Enhanced spinner */
#spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto;
    position: relative;
}

#spinner::before, #spinner::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
}

#spinner::before {
    border-top-color: var(--primary-light);
    border-right-color: var(--primary-mid);
    animation: spin 1s linear infinite;
}

#spinner::after {
    border-bottom-color: var(--primary-dark);
    border-left-color: var(--primary-light);
    animation: spin 1.5s linear infinite reverse;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Image container */
#image-container {
    display: none;
    margin: var(--spacing-lg) 0;
    text-align: center;
}

#image-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

#generated-image {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border: 2px solid var(--bg-mid-30);
}

/* Download button */
#download {
    display: none;
    width: 100%;
    margin-top: var(--spacing-md);
}

#download.active {
    display: inline-block;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: auto;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Gallery section */
.gallery-section {
    background: var(--bg-dark-15);
    border: 1px solid var(--bg-mid-30);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin: var(--spacing-lg) auto;
    position: relative;
    width: 100%;
    max-width: 100%;
}

.gallery-full-section {
    background: var(--bg-dark-15);
    border: 1px solid var(--bg-mid-30);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin: 0 auto var(--spacing-lg);
    max-width: 100%;
    min-height: 60vh;
}

.gallery-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--bg-mid-30);
}

.gallery-icon {
    font-size: 1.3rem;
}

.gallery-title {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gallery-container {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--spacing-sm);
    overflow-x: auto;
    padding: var(--spacing-xs) 0;
    min-height: 100px;
    width: 100%;
}

.gallery-empty {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: var(--spacing-md);
    width: 100%;
}

.gallery-item {
    flex: 0 0 auto;
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--bg-mid-30);
    transition: all 0.2s ease;
    background: var(--bg-dark-30);
}

.gallery-item:hover img {
    border-color: var(--primary);
}

/* Full Gallery Page Styles */
.gallery-full-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing-md);
}

.gallery-full-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-full-item:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.gallery-full-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--bg-mid-30);
    transition: all 0.2s ease;
    background: var(--bg-dark-30);
}

.gallery-full-item:hover img {
    border-color: var(--primary);
}

/* Gallery Popup Modal */
.gallery-popup {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.gallery-popup.active {
    opacity: 1;
    visibility: visible;
}

.gallery-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.gallery-popup-content {
    position: relative;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    max-width: 90vw;
    max-height: 90vh;
}

.gallery-popup-close {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 36px;
    height: 36px;
    border: 1px solid rgba(51, 177, 196, 0.4);
    border-radius: 50%;
    background: var(--bg-mid-50);
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1002;
}

.gallery-popup-close:hover {
    background: var(--primary-light);
    color: var(--text-dark);
}

.gallery-popup-image {
    max-width: 640px;
    max-height: 480px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-md);
    border: 3px solid var(--primary);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: popupScale 0.3s ease;
    cursor: pointer;
}

/* Full size popup for gallery page */
.gallery-full-page .gallery-popup-image {
    max-width: 640px;
    max-height: 480px;
}

@keyframes popupScale {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.gallery-popup-prompt-wrapper {
    position: relative;
    width: 100%;
    max-width: 640px;
}

.gallery-popup-prompt {
    background: var(--bg-dark-90);
    color: var(--text-light);
    padding: var(--spacing-md);
    padding-right: 50px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    text-align: left;
    border: 1px solid var(--bg-mid-30);
    animation: popupFadeIn 0.3s ease 0.15s both;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
    min-height: 1.4em;
    line-height: 1.4;
}

.gallery-popup-copy {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 6px;
    border: 1px solid rgba(51, 177, 196, 0.4);
    border-radius: var(--radius-sm);
    background: var(--bg-mid-30);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.gallery-popup-copy:hover {
    background: var(--primary-light);
    color: var(--text-dark);
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Status indicators */
.status-safe { color: #4ade80; }
.status-warning { color: #fbbf24; }
.status-danger { color: #f87171; }

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark-10);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-mid-50);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-mid-70);
}

/* Prompt tools row */
.prompt-tools {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    align-items: flex-end;
}

.tool-group {
    flex: 1;
    min-width: 120px;
}

.tool-group .input-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.tool-group select {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.9rem;
}

.prompt-tools .btn-secondary {
    white-space: nowrap;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.85rem;
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .app-container {
        padding: var(--spacing-xl);
    }
    
    .app-main {
        grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
        gap: var(--spacing-xl);
    }
    
    .input-section {
        grid-column: 1;
    }
    
    .output-section {
        grid-column: 2;
        display: flex;
        flex-direction: column;
    }
    
    #image-container {
        flex: 1;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        min-height: 300px;
    }
    
    #generated-image {
        max-height: 70vh;
    }
}

@media (max-width: 480px) {
    :root {
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .btn-generate {
        font-size: 1rem;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    #prompt {
        min-height: 100px;
    }
    
    .prompt-tools {
        flex-direction: column;
        align-items: stretch;
    }

    .tool-group {
        min-width: 100%;
    }

    .prompt-tools .btn-secondary {
        width: 100%;
    }
}

/* Service Page */
.service-content {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

.service-page-container {
    padding-top: 0;
    padding-bottom: var(--spacing-lg);
}

.generator-container {
    padding-top: 0;
}

body.auth-page {
    padding-top: 0 !important;
}

.auth-page .app-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

.service-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), var(--new-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.service-intro {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: var(--spacing-xl);
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.service-card {
    background: var(--bg-mid-15);
    border: 1px solid var(--bg-light-30);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
}

.service-card:hover {
    background: var(--bg-mid-20);
    border-color: var(--primary-light);
    transform: translateY(-4px);
}

.service-card h2 {
    font-size: 1.25rem;
    color: var(--text-light);
    margin-bottom: var(--spacing-sm);
}

.service-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.service-cta {
    text-align: center;
    margin-top: var(--spacing-xl);
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-mid-30);
    border: 1px solid rgba(51, 177, 196, 0.3);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: var(--spacing-xs);
}

.theme-toggle:hover {
    color: var(--text-light);
    background: var(--bg-mid-50);
    border-color: rgba(51, 177, 196, 0.5);
}

.theme-icon {
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-icon {
    transform: rotate(15deg);
}

/* Auth Pages */
.auth-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: calc(100vh - 120px);
    padding: var(--spacing-lg);
}

.auth-card {
    margin-top: var(--spacing-xl);
    background: var(--bg-mid-15);
    border: 1px solid var(--bg-light-30);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 400px;
}



.auth-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.auth-header svg {
    margin-bottom: var(--spacing-md);
}

.auth-header h1 {
    font-size: 1.75rem;
    color: var(--text-light);
    margin-bottom: var(--spacing-xs);
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.auth-form .form-group {
    margin-bottom: var(--spacing-md);
}

.auth-form .form-row {
    display: flex;
    gap: var(--spacing-md);
}

.auth-form .form-row .form-group {
    flex: 1;
}

.auth-form label {
    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.auth-form input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-dark-10);
    border: 2px solid var(--bg-mid-30);
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--bg-dark-15);
}

.auth-form input::placeholder {
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--bg-mid-30);
}

.auth-footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary-light);
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   LIGHT THEME - from light.html
   ============================================ */
[data-theme="light"] {
    --primary: #0faeae;
    --secondary: #ba0834;
    --tertiary: #1243a5;
    --gr-shift: #af0e79;
    --new-cyan: #51ecd2;
    --success: #0cc039;

    --text-primary: #0a1f2c;
    --text-secondary: #2a4a5f;

    --layer-1: rgba(223, 234, 241, 0.118);
    --layer-2: rgba(223, 234, 241, 0.236);
    --layer-3: rgba(223, 234, 241, 0.382);
    --layer-4: rgba(223, 234, 241, 0.618);
    --layer-5: rgba(223, 234, 241, 0.764);

    --text-light: var(--text-primary);
    --text-dark: #0a1f2c;
    --text-muted: var(--text-secondary);
    
    --gradient-primary: linear-gradient(135deg, #0faeae 0%, #51ecd2 100%);
    --gradient-dark: linear-gradient(135deg, #0faeae 0%, #1243a5 100%);
    --gradient-bg: linear-gradient(135deg, #ebf3f9 0%, #f0f7fb 100%);
}

[data-theme="light"] body {
    background: var(--gradient-bg);
    color: var(--text-light);
}

[data-theme="light"] .navbar {
    background: var(--layer-4);
    backdrop-filter: blur(32px);
    border-bottom: 1px solid rgba(15, 174, 174, 0.18);
}

[data-theme="light"] .nav-link {
    color: var(--text-secondary);
}

[data-theme="light"] .nav-link:hover {
    background: rgba(15, 174, 174, 0.1);
    border-color: rgba(15, 174, 174, 0.3);
}

[data-theme="light"] .nav-link.active {
    background: rgba(15, 174, 174, 0.15);
    border-color: rgba(15, 174, 174, 0.5);
    color: var(--text-primary);
}

[data-theme="light"] .card {
    background: var(--layer-2);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(15, 174, 174, 0.18);
}

[data-theme="light"] .card:hover {
    background: var(--layer-3);
    border-color: rgba(15, 174, 174, 0.3);
    box-shadow: 0 8px 32px rgba(15, 174, 174, 0.1);
}

[data-theme="light"] .theme-toggle {
    background: var(--layer-2);
    border-color: rgba(15, 174, 174, 0.18);
    color: var(--text-secondary);
}

[data-theme="light"] .theme-toggle:hover {
    background: var(--layer-3);
    color: var(--text-primary);
}

[data-theme="light"] #prompt,
[data-theme="light"] select,
[data-theme="light"] input[type="number"] {
    background: var(--layer-1);
    border: 2px solid rgba(15, 174, 174, 0.2);
    color: var(--text-primary);
}

[data-theme="light"] #prompt:focus,
[data-theme="light"] select:focus,
[data-theme="light"] input[type="number"]:focus {
    background: var(--layer-2);
    border-color: var(--primary);
}

[data-theme="light"] .gallery-section,
[data-theme="light"] .rate-limit-card,
[data-theme="light"] .gallery-full-section {
    background: var(--layer-2);
    border-color: rgba(15, 174, 174, 0.2);
}

[data-theme="light"] .gallery-item img {
    border-color: rgba(15, 174, 174, 0.3);
}

[data-theme="light"] .gallery-full-item img {
    border-color: rgba(15, 174, 174, 0.3);
}

[data-theme="light"] .app-header h1 {
    background: linear-gradient(90deg, #0faeae, #51ecd2);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: var(--layer-1);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(15, 174, 174, 0.3);
}


/* Navbar center title - matches heading style */
.navbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), var(--new-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    z-index: 1;
}

@media (max-width: 640px) {
    .navbar-center {
        font-size: 1.5rem;
    }
}

/* Gallery Row - Small row on generator page */
.gallery-row-section {
    margin: var(--spacing-lg) auto;
    padding: 0 var(--spacing-md);
    max-width: 100%;
}

.gallery-row-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.gallery-row-icon {
    font-size: 1.25rem;
}

.gallery-row-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #e0f0f8);
}

.gallery-row-link {
    font-size: 0.9rem;
    color: var(--primary, #0faeae);
    text-decoration: none;
    transition: color 0.2s;
}

.gallery-row-link:hover {
    color: var(--new-cyan, #00d4ff);
}

.gallery-row {
    display: flex;
    gap: var(--spacing-sm);
    overflow-x: auto;
    padding: var(--spacing-sm) 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.gallery-row::-webkit-scrollbar {
    height: 6px;
}

.gallery-row::-webkit-scrollbar-track {
    background: var(--bg-dark-15, rgba(45, 49, 66, 0.5));
    border-radius: 3px;
}

.gallery-row::-webkit-scrollbar-thumb {
    background: var(--bg-mid-30, rgba(255, 255, 255, 0.2));
    border-radius: 3px;
}

.gallery-row-item {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.gallery-row-item:hover {
    transform: scale(1.05);
    border-color: var(--primary, #0faeae);
    box-shadow: 0 4px 12px rgba(15, 174, 174, 0.3);
}

.gallery-row-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-row-loading,
.gallery-row-empty {
    color: var(--text-muted, #a8c8e0);
    font-size: 0.9rem;
    padding: var(--spacing-md);
}

@media (max-width: 640px) {
    .gallery-row-item {
        width: 80px;
        height: 80px;
    }
}
