/* Base styles: reset, theme variables, layout, navigation, status */

@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@500;600;700&display=swap');

:root {
    /* Surfaces */
    --bg-primary: #fafaf9;
    --bg-card: #ffffff;
    --bg-accent: #f4f4f2;
    --surface-tint: #fff8ee;

    /* Text */
    --text-primary: #0a0a0a;
    --text-secondary: rgba(10, 10, 10, 0.62);
    --text-muted: rgba(10, 10, 10, 0.42);

    /* Borders */
    --border-color: rgba(10, 10, 10, 0.08);
    --border-strong: rgba(10, 10, 10, 0.16);

    /* Semantic / accent */
    --color-gold: #d97706;
    --accent-soft: rgba(217, 119, 6, 0.10);
    --color-green: #15803d;
    --good-soft: rgba(21, 128, 61, 0.10);
    --color-blue: #0891b2;
    --color-pink: #db2777;
    --color-purple: #7c3aed;
    --color-lime: #65a30d;
    --color-warning: #f59e0b;
    --color-error: #dc2626;

    /* Per-device colors are emitted inline by the server using a procedural
       OKLCH palette (see src/solar_data/api/_palette.py). Templates set
       --device-color and --device-color-soft on each chip / chart container. */

    /* Typography */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 0;
}

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    margin-left: 220px;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: var(--color-gold);
    font-size: 2rem;
    margin-bottom: 5px;
}

.header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.section-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* Sidebar Navigation */
.sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
}

.sidebar-brand {
    margin-bottom: 14px;
}

.sidebar-brand .nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    color: var(--text-primary);
}

.nav-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 17px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.nav-brand__mark svg {
    height: 17px;
    width: auto;
    overflow: visible;
    display: block;
}

.nav-brand__name {
    font-family: 'Inter Tight', 'Inter', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.5px;
    line-height: 1;
    margin-left: -3px;
    font-feature-settings: "ss01", "cv11";
}

/* Em-based brand lockup for use outside the sidebar (auth pages, hero areas).
   Sized off the parent's font-size so it scales with the surrounding heading. */
.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 0;
    color: var(--text-primary);
    line-height: 1;
}

.brand-lockup__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.08em;
    flex-shrink: 0;
}

.brand-lockup__mark svg {
    height: 1.08em;
    width: auto;
    overflow: visible;
    display: block;
}

.brand-lockup__name {
    font-family: 'Inter Tight', 'Inter', system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-left: -0.22em;
    font-feature-settings: "ss01", "cv11";
}

.brand-heading {
    text-align: center;
    margin: 0 0 0.5rem;
    font-weight: 600;
}

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

.nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}

.nav-link {
    position: relative;
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

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

.nav-link.active {
    background: var(--accent-soft);
    color: var(--color-gold);
    font-weight: 500;
}

.nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--color-gold);
    border-radius: 2px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Site switcher (sidebar, every page) */
.site-switcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 7px;
    cursor: pointer;
    color: var(--text-primary);
    transition: border-color 0.12s;
}

.site-switcher:hover {
    border-color: var(--border-strong);
}

.site-switcher__label {
    flex: 1;
    min-width: 0;
}

.site-switcher__eyebrow {
    font-size: 9.5px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 600;
    line-height: 1;
}

.site-switcher__name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.1px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-switcher__chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    pointer-events: none;
}

/* Native select sits invisibly over the whole shell so clicks open it. */
.site-switcher__select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    background: transparent;
    font: inherit;
}

/* User section (sidebar) — name + email, no avatar */
.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
}

.nav-user-link {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    border-radius: 6px;
    transition: background 0.2s;
}

.nav-user-link:hover {
    background: var(--bg-accent);
}

.nav-user-name {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-email {
    color: var(--text-muted);
    font-size: 10px;
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-logout-form {
    flex-shrink: 0;
    margin: 0;
}

.nav-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

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

/* Status */
.status {
    text-align: center;
    padding: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.status.error {
    color: var(--color-error);
}

.last-update {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 20px;
}

.tz-label {
    color: var(--color-blue);
    font-weight: 600;
}

/* Mobile top bar — hidden by default, shown at ≤768px */
.mobile-topbar {
    display: none;
}

.nav-backdrop {
    display: none;
}

/* Mobile layout (≤768px) */
@media (max-width: 768px) {
    body.nav-open {
        overflow: hidden;
    }

    .dashboard {
        margin-left: 0;
        padding: 12px;
        padding-top: 68px; /* 56px top bar + 12px gap */
    }

    .header h1 {
        font-size: 1.4rem;
    }

    /* Top bar */
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        padding: 0 12px;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        z-index: 120;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: none;
        background: transparent;
        color: var(--text-primary);
        border-radius: 6px;
        cursor: pointer;
    }

    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:focus-visible {
        background: var(--bg-accent);
    }

    .mobile-topbar-brand {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        color: var(--color-gold);
        font-size: 1rem;
        font-weight: bold;
        pointer-events: none;
    }

    .mobile-topbar-avatar,
    .mobile-topbar-avatar-placeholder {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--bg-accent);
        color: var(--color-gold);
        font-size: 0.85rem;
        font-weight: 600;
        text-decoration: none;
        border: 1px solid var(--border-color);
    }

    /* Backdrop */
    .nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 130;
    }

    body.nav-open .nav-backdrop {
        display: block;
    }

    /* Sidebar becomes drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease-out;
        z-index: 140;
        width: 260px;
    }

    body.nav-open .sidebar {
        transform: translateX(0);
    }

    .sidebar .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}
