/* ═══════════════════════════════════════════════
   KidsAI - Color Themes
   Shared across all pages (chat, admin, login)
   ═══════════════════════════════════════════════ */

/* ─── Theme: Ocean 🌊 ─── */
[data-color-theme="ocean"] {
    --primary: #0077B6;
    --primary-dark: #005F8A;
    --primary-light: #48CAE4;
    --secondary: #FF6B6B;
    --secondary-light: #FF9999;
    --accent: #00B4D8;
    --accent-light: #90E0EF;
    --chat-bg: linear-gradient(160deg, #0077B6 0%, #00B4D8 100%);
    --sidebar-active: #e0f3ff;
}
[data-color-theme="ocean"][data-theme="dark"] {
    --primary: #48CAE4;
    --primary-dark: #0096C7;
    --primary-light: #90E0EF;
    --secondary: #FF8A8A;
    --secondary-light: #FFB3B3;
    --accent: #90E0EF;
    --accent-light: #CAF0F8;
    --chat-bg: linear-gradient(160deg, #03071e 0%, #002B44 100%);
    --sidebar-active: #0a2840;
}

/* ─── Theme: Sunset 🌅 ─── */
[data-color-theme="sunset"] {
    --primary: #F77F00;
    --primary-dark: #E07000;
    --primary-light: #FCBF49;
    --secondary: #D62828;
    --secondary-light: #E06060;
    --accent: #FCBF49;
    --accent-light: #FDE68A;
    --chat-bg: linear-gradient(160deg, #F77F00 0%, #D62828 100%);
    --sidebar-active: #fff3e0;
}
[data-color-theme="sunset"][data-theme="dark"] {
    --primary: #FCBF49;
    --primary-dark: #F77F00;
    --primary-light: #FDE68A;
    --secondary: #FF6B6B;
    --secondary-light: #FF9999;
    --accent: #FDE68A;
    --accent-light: #FEF3C7;
    --chat-bg: linear-gradient(160deg, #1a0a00 0%, #2a0a0a 100%);
    --sidebar-active: #2a1800;
}

/* ─── Theme: Forest 🌲 ─── */
[data-color-theme="forest"] {
    --primary: #2D6A4F;
    --primary-dark: #1B4332;
    --primary-light: #52B788;
    --secondary: #D62828;
    --secondary-light: #E06060;
    --accent: #40916C;
    --accent-light: #95D5B2;
    --chat-bg: linear-gradient(160deg, #2D6A4F 0%, #40916C 100%);
    --sidebar-active: #e8f5e9;
}
[data-color-theme="forest"][data-theme="dark"] {
    --primary: #52B788;
    --primary-dark: #40916C;
    --primary-light: #95D5B2;
    --secondary: #FF8A8A;
    --secondary-light: #FFB3B3;
    --accent: #95D5B2;
    --accent-light: #B7E4C7;
    --chat-bg: linear-gradient(160deg, #0a1a10 0%, #0d2818 100%);
    --sidebar-active: #0d2818;
}

/* ─── Theme: Candy 🍬 ─── */
[data-color-theme="candy"] {
    --primary: #FF69B4;
    --primary-dark: #E055A0;
    --primary-light: #FFB6C1;
    --secondary: #FF1493;
    --secondary-light: #FF69B4;
    --accent: #DA70D6;
    --accent-light: #E8A0E5;
    --chat-bg: linear-gradient(160deg, #FF69B4 0%, #DA70D6 100%);
    --sidebar-active: #ffe0f0;
}
[data-color-theme="candy"][data-theme="dark"] {
    --primary: #FFB6C1;
    --primary-dark: #FF69B4;
    --primary-light: #FFC0CB;
    --secondary: #FF69B4;
    --secondary-light: #FFB6C1;
    --accent: #E8A0E5;
    --accent-light: #F0C0EE;
    --chat-bg: linear-gradient(160deg, #1a0a14 0%, #1a0a1a 100%);
    --sidebar-active: #2a0a20;
}

/* ─── Theme: Space 🚀 ─── */
[data-color-theme="space"] {
    --primary: #5C4D7D;
    --primary-dark: #4A3D6B;
    --primary-light: #8D86C9;
    --secondary: #EF476F;
    --secondary-light: #F47D97;
    --accent: #FFD166;
    --accent-light: #FFE199;
    --chat-bg: linear-gradient(160deg, #2B2D42 0%, #5C4D7D 100%);
    --sidebar-active: #eeedf5;
}
[data-color-theme="space"][data-theme="dark"] {
    --primary: #8D86C9;
    --primary-dark: #5C4D7D;
    --primary-light: #B8B2E0;
    --secondary: #F47D97;
    --secondary-light: #F9A8BA;
    --accent: #FFE199;
    --accent-light: #FFF0CC;
    --chat-bg: linear-gradient(160deg, #07070F 0%, #151530 100%);
    --sidebar-active: #1a1840;
}

/* ─── Theme: Sunshine ☀️ ─── */
[data-color-theme="sunshine"] {
    --primary: #F3722C;
    --primary-dark: #E05A15;
    --primary-light: #F9844A;
    --secondary: #E63946;
    --secondary-light: #EE6B75;
    --accent: #F9C74F;
    --accent-light: #FDE68A;
    --chat-bg: linear-gradient(160deg, #F9C74F 0%, #F3722C 100%);
    --sidebar-active: #fff8e1;
}
[data-color-theme="sunshine"][data-theme="dark"] {
    --primary: #F9C74F;
    --primary-dark: #F3722C;
    --primary-light: #FDE68A;
    --secondary: #FF6B75;
    --secondary-light: #FF9DA5;
    --accent: #FDE68A;
    --accent-light: #FEF3C7;
    --chat-bg: linear-gradient(160deg, #1a1400 0%, #1a0e05 100%);
    --sidebar-active: #2a2000;
}

/* ─── Theme: Arctic ❄️ ─── */
[data-color-theme="arctic"] {
    --primary: #457B9D;
    --primary-dark: #1D3557;
    --primary-light: #A8DADC;
    --secondary: #E63946;
    --secondary-light: #EE6B75;
    --accent: #A8DADC;
    --accent-light: #C8E6E8;
    --chat-bg: linear-gradient(160deg, #A8DADC 0%, #457B9D 100%);
    --sidebar-active: #e8f4f5;
}
[data-color-theme="arctic"][data-theme="dark"] {
    --primary: #A8DADC;
    --primary-dark: #457B9D;
    --primary-light: #C8E6E8;
    --secondary: #FF6B75;
    --secondary-light: #FF9DA5;
    --accent: #C8E6E8;
    --accent-light: #E0F0F0;
    --chat-bg: linear-gradient(160deg, #0a1214 0%, #0d1a28 100%);
    --sidebar-active: #0d2030;
}

/* ─── Theme: Midnight 🌑 ─── */
[data-color-theme="midnight"] {
    --primary: #3A3A8C;
    --primary-dark: #2A2A6C;
    --primary-light: #6A6ABF;
    --secondary: #FF4757;
    --secondary-light: #FF6B81;
    --accent: #5352ED;
    --accent-light: #7B7BF0;
    --chat-bg: linear-gradient(160deg, #1e1e4a 0%, #3A3A8C 100%);
    --sidebar-active: #e8e8f5;
}
[data-color-theme="midnight"][data-theme="dark"] {
    --primary: #6A6ABF;
    --primary-dark: #3A3A8C;
    --primary-light: #9B9BD4;
    --secondary: #FF6B81;
    --secondary-light: #FF99AA;
    --accent: #7B7BF0;
    --accent-light: #A0A0F5;
    --chat-bg: linear-gradient(160deg, #08081a 0%, #141438 100%);
    --sidebar-active: #1a1a40;
}

/* ─── Theme: Ember 🔥 ─── */
[data-color-theme="ember"] {
    --primary: #B71C1C;
    --primary-dark: #8B0000;
    --primary-light: #E53935;
    --secondary: #FF6D00;
    --secondary-light: #FF9E40;
    --accent: #D84315;
    --accent-light: #F4511E;
    --chat-bg: linear-gradient(160deg, #B71C1C 0%, #D84315 100%);
    --sidebar-active: #fce4ec;
}
[data-color-theme="ember"][data-theme="dark"] {
    --primary: #E53935;
    --primary-dark: #B71C1C;
    --primary-light: #EF5350;
    --secondary: #FF9E40;
    --secondary-light: #FFBE76;
    --accent: #F4511E;
    --accent-light: #FF6E40;
    --chat-bg: linear-gradient(160deg, #1a0505 0%, #1a0a05 100%);
    --sidebar-active: #2a0a0a;
}

/* ─── Theme: Storm ⛈️ ─── */
[data-color-theme="storm"] {
    --primary: #37474F;
    --primary-dark: #263238;
    --primary-light: #607D8B;
    --secondary: #F06292;
    --secondary-light: #F48FB1;
    --accent: #4DB6AC;
    --accent-light: #80CBC4;
    --chat-bg: linear-gradient(160deg, #263238 0%, #37474F 100%);
    --sidebar-active: #eceff1;
}
[data-color-theme="storm"][data-theme="dark"] {
    --primary: #78909C;
    --primary-dark: #546E7A;
    --primary-light: #90A4AE;
    --secondary: #F48FB1;
    --secondary-light: #F8BBD0;
    --accent: #80CBC4;
    --accent-light: #B2DFDB;
    --chat-bg: linear-gradient(160deg, #0a0e10 0%, #101820 100%);
    --sidebar-active: #162028;
}

/* ═══════════════════════════════════════════════
   Theme Picker Popover
   ═══════════════════════════════════════════════ */

.theme-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 8px;
    right: 8px;
    background: var(--sidebar-bg, var(--card-bg, #fff));
    border: 1px solid var(--sidebar-border, var(--border, #e0e0e0));
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    z-index: 100;
    animation: pickerSlideUp 0.2s ease-out;
}
[data-theme="dark"] .theme-picker {
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

/* Admin uses dropdown instead of slide-up */
.theme-picker--dropdown {
    bottom: auto;
    top: calc(100% + 8px);
    left: auto;
    right: 0;
    width: 300px;
    animation: pickerDropDown 0.2s ease-out;
}

@keyframes pickerSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pickerDropDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.theme-picker-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--sidebar-text-secondary, #666);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    z-index: 1;
}
.theme-picker-close:hover {
    background: var(--sidebar-hover, #f0f0f0);
    color: var(--sidebar-text, #333);
}

.theme-picker-section {
    margin-bottom: 12px;
}
.theme-picker-section:last-child {
    margin-bottom: 0;
}

.theme-picker-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sidebar-text-secondary, var(--text-secondary, #666));
    margin-bottom: 8px;
}

.theme-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.theme-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
    position: relative;
}
.theme-swatch:hover {
    transform: scale(1.15);
}
.theme-swatch.active {
    border-color: var(--sidebar-text, var(--text, #333));
    box-shadow: 0 0 0 2px var(--sidebar-bg, var(--card-bg, #fff)), 0 0 0 4px var(--sidebar-text, var(--text, #333));
}

.accent-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}
.accent-swatch:hover {
    transform: scale(1.2);
}
.accent-swatch.active {
    border-color: var(--sidebar-text, var(--text, #333));
    box-shadow: 0 0 0 2px var(--sidebar-bg, var(--card-bg, #fff)), 0 0 0 3px var(--sidebar-text, var(--text, #333));
}

/* ─── Theme Picker: buddy emoji swatches ─── */
.buddy-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    position: relative;
    background: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .buddy-swatch {
    background: rgba(255, 255, 255, 0.06);
}
.buddy-swatch:hover {
    transform: scale(1.15);
    background: rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .buddy-swatch:hover {
    background: rgba(255, 255, 255, 0.12);
}
.buddy-swatch.active {
    border-color: var(--sidebar-text, var(--text, #333));
    box-shadow: 0 0 0 2px var(--sidebar-bg, var(--card-bg, #fff)), 0 0 0 3px var(--sidebar-text, var(--text, #333));
}
.buddy-check {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 14px;
    height: 14px;
    background: var(--accent, #43E97B);
    border-radius: 50%;
    font-size: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ─── Expandable Emoji Picker ─── */
.emoji-expand-btn {
    display: block;
    width: 100%;
    padding: 6px 0;
    margin-top: 8px;
    border: 1px dashed var(--sidebar-border, #e0e0e0);
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text-secondary, #666);
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.emoji-expand-btn:hover {
    background: var(--sidebar-hover, #f0f0f0);
    color: var(--sidebar-text, #333);
}
[data-theme="dark"] .emoji-expand-btn:hover {
    background: var(--sidebar-hover, #22223a);
}

.emoji-category {
    margin-bottom: 6px;
}

.emoji-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 5px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--sidebar-text-secondary, #666);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 4px;
}
.emoji-category-header:hover {
    background: var(--sidebar-hover, #f0f0f0);
}
[data-theme="dark"] .emoji-category-header:hover {
    background: var(--sidebar-hover, #22223a);
}

.emoji-cat-arrow {
    font-size: 0.6rem;
    opacity: 0.6;
}

/* Theme picker scrollable when expanded */
.theme-picker {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.theme-picker::-webkit-scrollbar { width: 4px; }
.theme-picker::-webkit-scrollbar-track { background: transparent; }
.theme-picker::-webkit-scrollbar-thumb { background: var(--sidebar-border, #e0e0e0); border-radius: 4px; }

/* ─── Theme Picker: mobile ─── */
@media (max-width: 768px) {
    .theme-picker {
        left: 6px;
        right: 6px;
        padding: 12px;
        border-radius: 12px;
    }
    .theme-swatch {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }
    .accent-swatch {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }
    .buddy-swatch {
        width: 30px;
        height: 30px;
        font-size: 17px;
    }
    .theme-picker--dropdown {
        position: fixed;
        left: 10px;
        right: 10px;
        width: auto;
        top: auto;
        bottom: 10px;
        animation: pickerSlideUp 0.2s ease-out;
    }
}

@media (max-width: 380px) {
    .theme-swatch {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
    .accent-swatch {
        width: 24px;
        height: 24px;
        font-size: 9px;
    }
    .buddy-swatch {
        width: 28px;
        height: 28px;
        font-size: 15px;
    }
    .theme-picker { padding: 10px; }
}
