/* ==========================================================================
   CandyShopLocale dashboard — design tokens
   Direction: a Göteborg pick-and-mix candy shop, grounded in its actual
   material culture (kraft-paper bags, polkagris red-and-white rock candy,
   Nordic restraint) rather than a generic rainbow "candy" look.
   ========================================================================== */

@font-face {
    font-family: 'Manrope';
    src: url('fonts/manrope-500.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Manrope';
    src: url('fonts/manrope-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Manrope';
    src: url('fonts/manrope-800.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-500.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --paper: #eef0ec;
    --paper-raised: #ffffff;
    --ink: #1b2320;
    --ink-soft: #5b6460;
    --hairline: #dde1db;
    --accent: #c8213f;
    --accent-soft: rgba(200, 33, 63, 0.12);
    --pine: #2f6f62;
    --caramel: #c98a3b;
    --slate: #8a9490;
    --sidebar-bg: #1b2320;
    --sidebar-text: #dfe6e2;
    --sidebar-text-dim: #8fa39a;
    --radius: 10px;
    --radius-sm: 7px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --font-display: 'Manrope', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

a {
    color: inherit;
}

button {
    font-family: inherit;
}

/* Focus visibility everywhere, including inside dark sidebar */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Shell layout
   ========================================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-shell__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: var(--space-4) var(--space-6) 0;
    position: relative;
}

.app-topbar__spacer {
    flex: 1;
}

.app-content {
    flex: 1;
    padding: var(--space-3) var(--space-6) var(--space-7);
    max-width: 1180px;
    width: 100%;
}

/* ==========================================================================
   Sidebar — the one bold gesture: a dark ink slab against the light canvas.
   ========================================================================== */

.side-nav {
    width: 236px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: var(--space-5) 0 var(--space-4);
    position: sticky;
    top: 0;
    height: 100vh;
}

.side-nav__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-5) var(--space-5);
}

.side-nav__brand-mark {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    background:
        repeating-linear-gradient(
            135deg,
            var(--accent) 0px,
            var(--accent) 2.5px,
            #fff 2.5px,
            #fff 5px
        );
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.side-nav__brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.side-nav__brand-text strong {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 800;
    color: #fff;
}

.side-nav__brand-text small {
    font-size: 12px;
    color: var(--sidebar-text-dim);
}

.side-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.side-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 11px var(--space-5);
    color: var(--sidebar-text-dim);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.side-nav__link svg {
    flex-shrink: 0;
    opacity: 0.85;
}

.side-nav__link:hover {
    color: var(--sidebar-text);
    background: rgba(255, 255, 255, 0.04);
}

.side-nav__link.active {
    color: #fff;
    border-left-color: var(--accent);
    background: rgba(255, 255, 255, 0.06);
}

.side-nav__footer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-5);
    color: var(--sidebar-text-dim);
    font-size: 12px;
}

.side-nav__footer-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4caf82;
    box-shadow: 0 0 0 3px rgba(76, 175, 130, 0.2);
}

/* ==========================================================================
   Page header
   ========================================================================== */

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.page-header h1 {
    font-size: 26px;
    letter-spacing: -0.01em;
}

.page-header p {
    margin: var(--space-1) 0 0;
    color: var(--ink-soft);
    font-size: 14px;
}

/* ==========================================================================
   Live indicator
   ========================================================================== */

.live-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--ink-soft);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.live-indicator__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pine);
    flex-shrink: 0;
}

.live-indicator__dot.is-pulsing {
    animation: live-pulse 0.9s ease-out;
}

@keyframes live-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(47, 111, 98, 0.45);
    }
    100% {
        box-shadow: 0 0 0 8px rgba(47, 111, 98, 0);
    }
}

/* ==========================================================================
   KPI tiles — flat page furniture, not boxed cards.
   ========================================================================== */

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.kpi-tile {
    border-bottom: 2px solid var(--hairline);
    padding-bottom: var(--space-3);
}

.kpi-tile__value {
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
    font-size: 32px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.1;
}

.kpi-tile__label {
    margin-top: var(--space-1);
    font-size: 13px;
    color: var(--ink-soft);
}

.kpi-tile__sublabel {
    margin-top: 2px;
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

/* ==========================================================================
   Chart cards — boxed modules, hairline only, no shadow/gradient.
   ========================================================================== */

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-5);
}

.chart-grid--wide {
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.chart-card {
    background: var(--paper-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chart-card__header h3 {
    font-size: 15px;
    font-weight: 700;
}

.chart-card__subtitle {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.chart-card__body {
    margin-top: var(--space-4);
    height: 260px;
    position: relative;
}

.chart-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--slate);
    font-size: 13.5px;
}

/* ==========================================================================
   Notifications — bell, activity panel, toasts
   ========================================================================== */

.notification-host {
    position: relative;
}

.bell-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--hairline);
    background: var(--paper-raised);
    color: var(--ink-soft);
    cursor: pointer;
}

.bell-button:hover {
    color: var(--ink);
    border-color: var(--slate);
}

.bell-button__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.activity-panel {
    position: absolute;
    right: 0;
    top: 44px;
    width: 320px;
    max-height: 380px;
    overflow-y: auto;
    background: var(--paper-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(27, 35, 32, 0.1);
    z-index: 30;
}

.activity-panel__header {
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    border-bottom: 1px solid var(--hairline);
}

.activity-panel__empty {
    padding: var(--space-4);
    color: var(--ink-soft);
    font-size: 13px;
    margin: 0;
}

.activity-panel__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-panel__list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--hairline);
    font-size: 13px;
}

.activity-panel__list li:last-child {
    border-bottom: none;
}

.activity-panel__headline {
    font-weight: 500;
}

.activity-panel__time {
    margin-left: auto;
    color: var(--slate);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.activity-panel__props {
    flex-basis: 100%;
    color: var(--ink-soft);
    font-size: 12px;
}

.toast-stack {
    position: fixed;
    right: var(--space-5);
    bottom: var(--space-5);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-2);
    z-index: 40;
    pointer-events: none;
}

.toast {
    background: var(--paper-raised);
    border: 1px solid var(--hairline);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    min-width: 220px;
    max-width: 300px;
    box-shadow: 0 6px 20px rgba(27, 35, 32, 0.12);
    animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast__headline {
    font-size: 13.5px;
    font-weight: 500;
}

.toast__detail {
    margin-top: 2px;
    font-size: 12px;
    color: var(--ink-soft);
}

/* ==========================================================================
   Misc
   ========================================================================== */

#blazor-error-ui {
    background: #fff3f2;
    border-top: 2px solid var(--accent);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.08);
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 14px;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.9rem;
    top: 0.7rem;
}

@media (max-width: 860px) {
    .app-shell {
        flex-direction: column;
    }

    .side-nav {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        padding: var(--space-3) var(--space-4);
    }

    .side-nav__brand {
        padding: 0;
    }

    .side-nav__list {
        display: flex;
        flex: none;
        margin-left: var(--space-4);
    }

    .side-nav__link {
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: var(--space-2) var(--space-3);
    }

    .side-nav__link.active {
        border-bottom-color: var(--accent);
    }

    .side-nav__link span:last-child {
        display: none;
    }

    .side-nav__footer {
        display: none;
    }

    .app-content {
        padding: var(--space-3) var(--space-4) var(--space-6);
    }

    .app-topbar {
        padding: var(--space-3) var(--space-4) 0;
    }
}
