/* ═══════════════════════════════════════════════════════════
   GERARMONÍA — Design System & Core Layout
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Variables ────────────────────────────────────── */
:root {
    /* Background */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #222845;
    --bg-surface: #161b2e;
    --bg-input: #1e2440;

    /* Text */
    --text-primary: #e8ecf4;
    --text-secondary: #8b95b0;
    --text-muted: #5a6380;
    --text-accent: #FFD700;

    /* Interval colors */
    --color-root: #FFD700;
    --color-third-major: #27AE60;
    --color-third-minor: #2ECC71;
    --color-fifth: #2980B9;
    --color-seventh-major: #8E44AD;
    --color-seventh-minor: #9B59B6;
    --color-altered: #E74C3C;

    /* UI Colors */
    --accent-primary: #6C5CE7;
    --accent-secondary: #00CEC9;
    --accent-warm: #FFD700;
    --accent-success: #2ECC71;
    --accent-danger: #E74C3C;
    --accent-info: #3498DB;

    /* Gradients */
    --gradient-hero: linear-gradient(135deg, #6C5CE7 0%, #00CEC9 100%);
    --gradient-accent: linear-gradient(135deg, #FFD700 0%, #FF6B35 100%);
    --gradient-card: linear-gradient(145deg, #1a1f35 0%, #161b2e 100%);

    /* Borders */
    --border-subtle: rgba(255,255,255,0.06);
    --border-medium: rgba(255,255,255,0.1);
    --border-active: rgba(108,92,231,0.5);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(108,92,231,0.3);

    /* Layout */
    --header-height: 56px;
    --sidebar-width: 220px;
    --bottom-tabs-height: 64px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Typography */
    --font-main: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-display: 'Outfit', 'Inter', sans-serif;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    height: 100%;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: grid;
    grid-template-rows: var(--header-height) 1fr var(--bottom-tabs-height);
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
        "header header"
        "sidebar main"
        "tabs tabs";
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ─── Header ───────────────────────────────────────────── */
.app-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition-fast);
}

.app-logo {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-primary);
}

.logo-accent {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.xp-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.xp-level {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-warm);
    background: rgba(255,215,0,0.1);
    padding: 2px 8px;
    border-radius: 20px;
}

.xp-bar-container {
    width: 60px;
    height: 4px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.xp-bar {
    height: 100%;
    background: var(--gradient-accent);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.xp-value {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.streak-display {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ─── Sidebar ──────────────────────────────────────────── */
.sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: 16px 8px;
    overflow-y: auto;
    z-index: 90;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    width: 100%;
    font-family: var(--font-main);
}

.nav-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-btn.active {
    background: rgba(108,92,231,0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 80;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.visible {
    opacity: 1;
}

/* ─── Main Content ─────────────────────────────────────── */
.main-content {
    grid-area: main;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.content-area {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100%;
}

/* ─── Bottom Tabs (mobile) ─────────────────────────────── */
.bottom-tabs {
    grid-area: tabs;
    display: none;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    padding: 4px 0;
    padding-bottom: env(safe-area-inset-bottom, 4px);
    z-index: 100;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: var(--font-main);
    cursor: pointer;
    transition: var(--transition-fast);
    border-radius: 8px;
    min-width: 52px;
}

.tab-btn.active {
    color: var(--accent-primary);
}

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

.tab-label {
    font-weight: 500;
}

/* ─── Mobile Responsive ────────────────────────────────── */
@media (max-width: 768px) {
    #app {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main"
            "tabs";
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: var(--header-height);
        bottom: 0;
        width: 260px;
        transition: left var(--transition-slow);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: block;
    }

    .menu-toggle {
        display: flex;
    }

    .bottom-tabs {
        display: flex;
    }

    .content-area {
        padding: 16px;
        padding-bottom: 24px;
    }

    .xp-bar-container { display: none; }
}

/* ─── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
