/* ===== Whisk Style — Light Theme ===== */
:root {
    --primary-hue: 45;
    --primary: hsl(var(--primary-hue), 100%, 50%);
    --primary-light: hsl(var(--primary-hue), 100%, 60%);
    --primary-dark: hsl(var(--primary-hue), 100%, 40%);
    --accent: hsl(35, 100%, 55%);
    --success: hsl(150, 70%, 42%);
    --warning: hsl(40, 100%, 55%);
    --error: hsl(0, 75%, 55%);

    /* Light theme */
    --bg-primary: #f8f8f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eeeeee;
    --bg-elevated: #f0f0f0;
    --sidebar-bg: hsl(var(--primary-hue), 100%, 50%);
    --text-primary: #1a1a1a;
    --text-secondary: #555;
    --text-muted: #999;
    --text-dark: #111;
    --border-color: rgba(0,0,0,0.08);
    --border-color-hover: rgba(0,0,0,0.15);
    --glass-bg: rgba(255,255,255,0.85);
    --glass-border: rgba(0,0,0,0.06);
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 20px rgba(255,200,0,0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== App Shell ===== */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

/* ===== BG Animation (subtle for light) ===== */
.bg-animation { display: none; }

/* ===== Top Bar ===== */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 20px; background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color); z-index: 100;
    flex-shrink: 0;
}
.top-bar-left { display: flex; align-items: center; gap: 10px; }
.logo-icon {
    width: 36px; height: 36px; background: var(--gradient-primary);
    border-radius: var(--radius-sm); display: flex; align-items: center;
    justify-content: center; box-shadow: var(--shadow-sm);
}
.logo-icon svg { width: 20px; height: 20px; color: var(--text-dark); }
.top-bar-left h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
.gradient-text { background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.top-bar-center { display: flex; gap: 4px; background: var(--bg-tertiary); padding: 3px; border-radius: var(--radius-full); }
.tab-btn {
    display: flex; align-items: center; gap: 6px; padding: 7px 16px;
    background: transparent; border: none; border-radius: var(--radius-full);
    color: var(--text-muted); font-family: inherit; font-size: 0.82rem;
    font-weight: 500; cursor: pointer; transition: all var(--transition-fast);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.top-bar-right { display: flex; align-items: center; gap: 8px; }
.stats-badge {
    display: flex; align-items: center; gap: 5px; padding: 5px 12px;
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: var(--radius-full); font-size: 0.78rem; color: var(--primary-dark);
    font-weight: 600;
}
.icon-btn {
    width: 34px; height: 34px; background: var(--bg-tertiary);
    border: 1px solid var(--border-color); border-radius: 50%;
    color: var(--text-secondary); cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--primary); }

/* ===== Main Layout ===== */
.main-layout { display: flex; flex: 1; overflow: hidden; }

/* ===== Sidebar (Yellow) ===== */
.sidebar {
    width: 200px; flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(0,0,0,0.08);
    overflow-y: auto; overflow-x: hidden;
}
.sidebar-scroll { padding: 14px 12px; }

.ref-section { margin-bottom: 14px; }
.ref-header { margin-bottom: 6px; }
.ref-header h3 { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.1em; color: var(--text-dark); text-transform: uppercase; }
.ref-hint { font-size: 0.6rem; color: rgba(0,0,0,0.45); }

.ref-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.ref-add-btn {
    width: 50px; height: 50px; border-radius: var(--radius-sm);
    border: 2px dashed rgba(0,0,0,0.2); background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: rgba(0,0,0,0.35);
    transition: all var(--transition-fast);
}
.ref-add-btn:hover { border-color: rgba(0,0,0,0.4); background: rgba(255,255,255,0.35); }
.ref-add-large {
    width: 100%; height: 100px; flex-direction: column; gap: 4px;
    font-size: 0.7rem; font-weight: 500;
}
.ref-add-large span { color: rgba(0,0,0,0.4); }
.ref-thumb {
    width: 70px; height: 70px; border-radius: var(--radius-sm);
    overflow: hidden; position: relative;
    border: 2px solid rgba(255,255,255,0.4);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-thumb-remove {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
    background: rgba(0,0,0,0.6); border: none; border-radius: 50%;
    color: white; font-size: 9px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity var(--transition-fast);
}
.ref-thumb:hover .ref-thumb-remove { opacity: 1; }
.ref-thumb-check {
    position: absolute; bottom: 3px; right: 3px; width: 18px; height: 18px;
    background: var(--success); border-radius: 50%; color: white;
    font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.ref-thumb-status {
    position: absolute; bottom: 3px; right: 3px; width: 18px; height: 18px;
    border-radius: 50%; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.ref-thumb-status.uploading {
    background: var(--warning); color: var(--text-dark);
    animation: spin 1.5s linear infinite;
}
.ref-thumb-status.error {
    background: var(--error); color: white;
}

/* ===== Content Area ===== */
.content-area {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-primary); overflow: hidden; position: relative;
}

.output-container { flex: 1; overflow-y: auto; padding: 0; padding-bottom: 60px; }

/* ===== Empty State ===== */
.empty-state { display: flex; align-items: center; justify-content: center; height: 100%; text-align: center; }
.empty-visual { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-icon-ring {
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--bg-tertiary); display: flex;
    align-items: center; justify-content: center;
    color: var(--text-muted); border: 2px solid var(--border-color);
}
.empty-visual h3 { font-size: 1rem; color: var(--text-secondary); font-weight: 500; }
.empty-visual p { font-size: 0.82rem; color: var(--text-muted); max-width: 280px; }

/* ===== Image Grid ===== */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 3px; width: 100%; }
@media (min-width: 1200px) { .image-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
@media (max-width: 768px) { .image-grid { grid-template-columns: repeat(2, 1fr); gap: 2px; } }

.image-card {
    position: relative; overflow: hidden;
    background: #222; cursor: pointer;
    transition: opacity var(--transition-fast);
}
.image-card:hover { opacity: 0.9; }
.image-card img { width: 100%; height: 100%; object-fit: cover; display: block; }

.image-overlay {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
    display: flex; justify-content: flex-end; gap: 6px;
    opacity: 0; transition: opacity var(--transition-normal);
}
.image-card:hover .image-overlay { opacity: 1; }
.overlay-btn {
    width: 32px; height: 32px; background: rgba(255,255,255,0.25);
    backdrop-filter: blur(8px); border: none; border-radius: var(--radius-sm);
    color: white; cursor: pointer; display: flex; align-items: center;
    justify-content: center; transition: background var(--transition-fast);
}
.overlay-btn:hover { background: rgba(255,255,255,0.4); }
.overlay-btn svg { width: 16px; height: 16px; }

/* Skeleton */
.image-card.skeleton {
    background: linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite; min-height: 180px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.prompt-bar {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    width: 640px; max-width: calc(100% - 32px); z-index: 50;
}
.prompt-bar-inner {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 5px 5px 14px;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-full); box-shadow: var(--shadow-md);
}
.prompt-settings { display: flex; gap: 3px; flex-shrink: 0; }
.prompt-select {
    padding: 3px 18px 3px 6px; background: var(--bg-tertiary);
    border: 1px solid var(--border-color); border-radius: 6px;
    color: var(--text-primary); font-family: inherit; font-size: 0.72rem;
    cursor: pointer; transition: all var(--transition-fast);
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 5px center;
}
.prompt-select:hover { border-color: var(--primary); }
.prompt-select:focus { outline: none; border-color: var(--primary); }
.prompt-input {
    flex: 1; background: transparent; border: none; color: var(--text-primary);
    font-family: inherit; font-size: 0.85rem; height: 28px;
}
.prompt-input::placeholder { color: var(--text-muted); }
.prompt-input:focus { outline: none; }

.generate-btn {
    width: 34px; height: 34px; flex-shrink: 0;
    background: var(--gradient-primary); border: none; border-radius: 50%;
    color: var(--text-dark); cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-normal);
    font-weight: 700;
}
.generate-btn:hover { transform: scale(1.08); box-shadow: var(--shadow-glow); }
.generate-btn.loading .btn-content { display: none; }
.generate-btn.loading .btn-loader { display: flex; }
.btn-loader { display: none; }
.spinner { width: 20px; height: 20px; border: 3px solid transparent; border-top-color: var(--text-dark); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Library ===== */
.library-page { flex: 1; overflow-y: auto; padding: 24px 32px; }
.library-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.library-header h2 { font-size: 1.2rem; }
.library-actions { display: flex; align-items: center; gap: 10px; }
.library-stats { font-size: 0.82rem; color: var(--text-secondary); padding: 5px 12px; background: var(--bg-secondary); border-radius: var(--radius-full); border: 1px solid var(--border-color); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

.action-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 7px 12px; background: var(--bg-secondary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    color: var(--text-secondary); font-family: inherit; font-size: 0.78rem;
    cursor: pointer; transition: all var(--transition-fast);
}
.action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.action-btn.danger:hover { background: rgba(220,50,50,0.08); color: var(--error); border-color: var(--error); }

/* ===== Admin Modal (dark) ===== */
.modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(6px); }
.modal-dialog {
    position: relative; width: 500px; max-width: 95vw; max-height: 90vh;
    background: #2a2a2a; border-radius: var(--radius-xl);
    border: 1px solid rgba(255,255,255,0.08); overflow-y: auto;
    box-shadow: var(--shadow-lg); animation: modalIn 0.3s ease;
    color: #eee;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.modal-header h2 { font-size: 1rem; color: #eee; }
.modal-close-btn {
    width: 30px; height: 30px; background: rgba(255,255,255,0.08); border: none;
    border-radius: 50%; color: #aaa; font-size: 14px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.modal-close-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.modal-body { padding: 22px; }

.admin-section { margin-bottom: 22px; }
.admin-section h3 { font-size: 0.85rem; font-weight: 600; margin-bottom: 10px; color: var(--primary); }
.admin-field { margin-bottom: 10px; }
.admin-field label { display: block; font-size: 0.78rem; color: #aaa; margin-bottom: 4px; }
.admin-input, .admin-textarea {
    width: 100%; padding: 9px 11px; background: #1e1e1e;
    border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm);
    color: #eee; font-family: inherit; font-size: 0.82rem;
    transition: border-color var(--transition-fast);
}
.admin-input:focus, .admin-textarea:focus { outline: none; border-color: var(--primary); }
.admin-textarea { resize: vertical; min-height: 80px; }

.admin-btn {
    padding: 9px 16px; background: #333;
    border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm);
    color: #eee; font-family: inherit; font-size: 0.82rem;
    cursor: pointer; transition: all var(--transition-fast);
}
.admin-btn:hover { background: #444; border-color: var(--primary); }
.admin-btn.primary { background: var(--gradient-primary); color: var(--text-dark); border: none; font-weight: 600; }
.admin-btn.primary:hover { box-shadow: var(--shadow-glow); }

/* Accounts List */
.accounts-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.empty-accounts { color: #888; font-size: 0.78rem; padding: 14px; text-align: center; background: #1e1e1e; border-radius: var(--radius-sm); }
.account-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    background: #1e1e1e; border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm); transition: all var(--transition-fast);
}
.account-item:hover { border-color: rgba(255,255,255,0.12); }
.account-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.account-dot.ready { background: var(--success); box-shadow: 0 0 5px var(--success); }
.account-dot.error { background: var(--error); }
.account-info { flex: 1; min-width: 0; }
.account-label { font-size: 0.8rem; font-weight: 500; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta { font-size: 0.68rem; color: #888; }
.account-count { font-size: 0.72rem; color: var(--primary); font-weight: 600; margin-right: 6px; }
.account-remove {
    width: 22px; height: 22px; background: transparent; border: 1px solid rgba(255,255,255,0.08);
    border-radius: 50%; color: #888; font-size: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.account-remove:hover { background: rgba(220,50,50,0.15); color: var(--error); border-color: var(--error); }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card {
    padding: 14px; background: #1e1e1e;
    border: 1px solid rgba(255,255,255,0.06); border-radius: var(--radius-md);
    text-align: center;
}
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.stat-label { font-size: 0.68rem; color: #888; text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== Preview Modal ===== */
.preview-content {
    position: relative; max-width: 90vw; max-height: 90vh;
    display: flex; flex-direction: column; align-items: center;
    animation: modalIn 0.3s ease;
}
.preview-content img { max-width: 100%; max-height: calc(90vh - 70px); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.preview-close { position: absolute; top: -40px; right: 0; }
.preview-actions { margin-top: 10px; }
.preview-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 9px 20px; background: var(--gradient-primary); border: none;
    border-radius: var(--radius-full); color: var(--text-dark);
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: transform var(--transition-fast);
}
.preview-btn:hover { transform: scale(1.05); }

/* ===== Toast ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 10px 16px; background: #333; border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md); color: #eee; font-size: 0.82rem;
    box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; display: flex; align-items: center; gap: 6px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
@keyframes slideIn { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(60px); } }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
::selection { background: rgba(255,200,0,0.25); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    /* Layout */
    .main-layout { flex-direction: column; }

    /* Sidebar → horizontal scroll */
    .sidebar {
        width: 100%; max-height: 140px; border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.08);
    }
    .sidebar-scroll {
        display: flex; gap: 12px; overflow-x: auto;
        padding: 10px; -webkit-overflow-scrolling: touch;
    }
    .ref-section { min-width: 110px; margin-bottom: 0; flex-shrink: 0; }
    .ref-add-large { height: 70px; }
    .ref-thumb { width: 55px; height: 55px; }

    /* Top bar → hide stats, shrink logo text */
    .top-bar { padding: 6px 12px; }
    .top-bar-left h1 { font-size: 1rem; }
    .stats-badge { display: none; }

    /* Tabs → Fixed bottom navigation */
    .top-bar-center {
        display: flex !important;
        position: fixed; bottom: 0; left: 0; right: 0;
        z-index: 200;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        border-radius: 0;
        padding: 4px 0;
        justify-content: center;
        gap: 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    }
    .tab-btn {
        flex: 1; flex-direction: column; gap: 2px;
        padding: 8px 0; border-radius: 0;
        font-size: 0.7rem; justify-content: center;
    }
    .tab-btn svg { width: 20px; height: 20px; }
    .tab-btn.active {
        background: transparent; color: var(--primary-dark);
        box-shadow: none; border-top: 2px solid var(--primary);
    }

    /* Content area → add bottom padding for nav */
    .content-area { padding-bottom: 60px; }
    .output-container { padding-bottom: 100px; }

    /* Prompt bar → adjust for bottom nav */
    .prompt-bar {
        bottom: 64px; width: calc(100% - 24px);
        left: 12px; transform: none;
    }
    .prompt-bar-inner { padding: 4px 4px 4px 10px; }
    .prompt-input { font-size: 0.8rem; }
    .prompt-select { font-size: 0.68rem; padding: 2px 15px 2px 4px; }

    /* Image grid → 2 columns on mobile */
    .image-grid { grid-template-columns: repeat(2, 1fr); gap: 2px; }

    /* Library → pad for bottom nav */
    .library-page {
        padding: 16px 12px 80px 12px;
    }
    .library-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .library-header h2 { font-size: 1rem; }
    .library-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

    /* Toast → above bottom nav */
    .toast-container { bottom: 70px; right: 12px; left: 12px; }
    .toast { font-size: 0.78rem; }

    /* Empty state */
    .empty-icon-ring { width: 60px; height: 60px; }
    .empty-icon-ring svg { width: 32px; height: 32px; }
    .empty-visual h3 { font-size: 0.9rem; }
    .empty-visual p { font-size: 0.75rem; }

    /* Preview modal */
    .preview-content { max-width: 95vw; }
    .preview-close { top: -35px; right: 5px; }
}

/* Small phones */
@media (max-width: 380px) {
    .prompt-settings { gap: 2px; }
    .prompt-select { padding: 2px 14px 2px 3px; font-size: 0.65rem; }
    .image-grid { grid-template-columns: repeat(2, 1fr); }
    .ref-section { min-width: 95px; }
}
