/* SigmaLab Theme System */

/* ===== BASE ===== */
:root {
    --bg: #0d0d0d;
    --fg: #f0f0f0;
    --muted: #999999;
    --accent: #d4a574;
    --border: rgba(255,255,255,0.12);
    --card: rgba(255,255,255,0.04);
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, sans-serif;
    --radius: 8px;
    --text-size: 1rem;
    --heading-size: 2rem;
}

html { font-size: 16px; }
@media (max-width: 600px) { html { font-size: 18px; } }

/* ===== THEMES ===== */

/* 1. Editorial Dark (default) */
:root, [data-theme="editorial"] {
    --bg: #0d0d0d; --fg: #f0f0f0; --muted: #888888;
    --accent: #d4a574; --border: rgba(255,255,255,0.1); --card: rgba(255,255,255,0.03);
    --font-display: 'Cormorant Garamond', serif; --font-body: 'DM Sans', sans-serif;
    --radius: 4px; --text-size: 1rem; --heading-size: 2rem;
}

/* 2. Light Editorial */
[data-theme="light-editorial"] {
    --bg: #ffffff; --fg: #1a1a1a; --muted: #666666;
    --accent: #8b4513; --border: rgba(0,0,0,0.1); --card: rgba(0,0,0,0.02);
    --font-display: 'Cormorant Garamond', serif; --font-body: 'DM Sans', sans-serif;
    --radius: 4px; --text-size: 1rem; --heading-size: 2rem;
}

/* 3. Retro Terminal */
[data-theme="retro-future"] {
    --bg: #0a0a12; --fg: #00ff88; --muted: #4a9f7a;
    --accent: #ff0066; --border: rgba(0,255,136,0.2); --card: rgba(0,255,136,0.03);
    --font-display: 'Space Mono', monospace; --font-body: 'Space Mono', monospace;
    --radius: 0; --text-size: 0.95rem; --heading-size: 2rem;
}
[data-theme="retro-future"] .card, [data-theme="retro-future"] input, [data-theme="retro-future"] .btn { border-width: 2px; text-transform: uppercase; letter-spacing: 1px; }

/* 4. Warm Organic */
[data-theme="organic"] {
    --bg: #f5f0e8; --fg: #3d3428; --muted: #7a6f5d;
    --accent: #c17d4a; --border: rgba(61,52,40,0.15); --card: rgba(255,255,255,0.6);
    --font-display: 'Lora', serif; --font-body: 'Lora', serif;
    --radius: 24px; --text-size: 1.05rem; --heading-size: 2rem;
}
[data-theme="organic"] .card, [data-theme="organic"] input { border: none; }

/* 5. Luxury */
[data-theme="luxury"] {
    --bg: #0f0f0f; --fg: #f8f8f8; --muted: #888888;
    --accent: #c9a962; --border: rgba(201,169,98,0.15); --card: rgba(201,169,98,0.03);
    --font-display: 'Playfair Display', serif; --font-body: 'Crimson Pro', serif;
    --radius: 2px; --text-size: 1.1rem; --heading-size: 2rem;
}

/* 6. Brutalist */
[data-theme="brutalist"] {
    --bg: #ffffff; --fg: #000000; --muted: #666666;
    --accent: #ff0000; --border: #000000; --card: #ffffff;
    --font-display: 'Arial Black', sans-serif; --font-body: 'Courier New', monospace;
    --radius: 0; --text-size: 1rem; --heading-size: 2rem;
}
[data-theme="brutalist"] .card, [data-theme="brutalist"] input { border-width: 3px; box-shadow: 4px 4px 0 #000; }
[data-theme="brutalist"] .btn-primary { background: var(--accent); color: #fff; }

/* 7. Playful */
[data-theme="playful"] {
    --bg: #fffbf0; --fg: #2d2d2d; --muted: #888888;
    --accent: #6c5ce7; --border: rgba(108,92,231,0.2); --card: #ffffff;
    --font-display: 'Poppins', sans-serif; --font-body: 'Poppins', sans-serif;
    --radius: 20px; --text-size: 1rem; --heading-size: 2rem;
}
[data-theme="playful"] .btn-primary { background: var(--accent); border: none; color: #fff; border-radius: 50px; }

/* 8. High Contrast */
[data-theme="high-contrast"] {
    --bg: #000000; --fg: #ffffff; --muted: #cccccc;
    --accent: #ffb366; --border: rgba(255,255,255,0.25); --card: rgba(255,255,255,0.08);
    --font-display: 'Cormorant Garamond', serif; --font-body: 'DM Sans', sans-serif;
    --radius: 8px; --text-size: 1.1rem; --heading-size: 2rem;
}

/* ===== APPLY ===== */
body { font-family: var(--font-body); font-size: var(--text-size); background: var(--bg); color: var(--fg); }
h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: var(--heading-size); }
h2 { font-size: calc(var(--heading-size) * 0.7); }
h3 { font-size: calc(var(--heading-size) * 0.55); }
.card, .btn, input { border-radius: var(--radius); background: var(--card); border-color: var(--border); }

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    position: fixed; top: 16px; right: 16px; z-index: 10000;
    background: var(--card); border: 1px solid var(--border); color: var(--fg);
    width: 48px; height: 48px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
    transition: all 0.3s;
}
@media (max-width: 600px) { .theme-toggle { width: 56px; height: 56px; font-size: 24px; } }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ===== THEME PANEL ===== */
.theme-selector {
    position: fixed; top: 76px; right: 16px; z-index: 9999;
    background: var(--bg); border: 1px solid var(--border); border-radius: 16px;
    padding: 20px; min-width: 220px; max-width: 90vw; max-height: 80vh;
    overflow-y: auto; display: none;
}
@media (max-width: 600px) { .theme-selector { top: 84px; right: 8px; left: 8px; min-width: auto; max-width: none; } }
.theme-selector.open { display: block; }
.theme-selector h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin: 0 0 16px 0; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.theme-option {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; margin: 6px 0; border-radius: 12px;
    cursor: pointer; transition: all 0.2s;
    background: var(--card); border: 1px solid var(--border);
}
@media (max-width: 600px) { .theme-option { padding: 16px 18px; } }
.theme-option:hover { background: var(--card); border-color: var(--accent); }
.theme-option.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.theme-swatch {
    width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0;
    border: 2px solid rgba(0,0,0,0.2); position: relative; overflow: hidden;
}
@media (max-width: 600px) { .theme-swatch { width: 40px; height: 40px; } }

/* SWATCH COLORS - Fixed per theme */
.theme-swatch.editorial { background: linear-gradient(135deg, #0d0d0d 50%, #d4a574 50%); }
.theme-swatch.light-editorial { background: linear-gradient(135deg, #ffffff 50%, #8b4513 50%); border-color: #ccc; }
.theme-swatch.retro-future { background: linear-gradient(135deg, #0a0a12 50%, #00ff88 50%); }
.theme-swatch.organic { background: linear-gradient(135deg, #f5f0e8 50%, #c17d4a 50%); border-color: #ccc; }
.theme-swatch.luxury { background: linear-gradient(135deg, #0f0f0f 50%, #c9a962 50%); }
.theme-swatch.brutalist { background: linear-gradient(135deg, #ffffff 50%, #ff0000 50%); border: 3px solid #000; }
.theme-swatch.playful { background: linear-gradient(135deg, #fffbf0 50%, #6c5ce7 50%); border-color: #ccc; }
.theme-swatch.high-contrast { background: linear-gradient(135deg, #000000 50%, #ffb366 50%); }
.theme-swatch.system { background: linear-gradient(135deg, #0d0d0d 50%, #ffffff 50%); border-color: #555; }

.theme-label { font-size: 14px; color: var(--fg); flex: 1; }
@media (max-width: 600px) { .theme-label { font-size: 16px; } }
.theme-check { color: var(--accent); font-size: 16px; opacity: 0; }
.theme-option.active .theme-check { opacity: 1; }

/* ===== FONT SIZE CONTROL ===== */
.font-size-control {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
.font-size-control label { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.font-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--card); color: var(--fg);
    font-size: 18px; font-weight: bold; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
@media (max-width: 600px) { .font-btn { width: 44px; height: 44px; font-size: 22px; } }
.font-btn:hover { border-color: var(--accent); color: var(--accent); }
.font-size-display { min-width: 48px; text-align: center; font-size: 14px; color: var(--fg); font-weight: 500; }

/* Apply font scale */
html { --font-scale: 1; }
html body { font-size: calc(var(--text-size) * var(--font-scale)); }
html h1 { font-size: calc(var(--heading-size) * var(--font-scale)); }
html h2 { font-size: calc(var(--heading-size) * 0.7 * var(--font-scale)); }
html h3 { font-size: calc(var(--heading-size) * 0.55 * var(--font-scale)); }

/* ===== MOBILE ===== */
@media (max-width: 600px) {
    .btn { padding: 14px 20px; font-size: 15px; }
    input { padding: 14px; font-size: 16px; }
    .card { padding: 20px; }
}
