/* ─── Theme tokens ────────────────────────
   Semantic colors used by both MudBlazor chrome and custom inline styles.
   Dark values flip when ThemeService sets html[data-theme="dark"].
   Brand/semantic accents (#00B5A6 teal, status colors) are intentionally
   theme-independent and stay hardcoded at call sites. */
:root {
    --sd-surface: #FFFFFF;
    --sd-bg-subtle: #F9FAFB;
    --sd-border: #E9ECEF;
    --sd-text: #212529;
    --sd-text-secondary: #6C757D;
    --sd-text-muted: #9CA3AF;
    --sd-accent-soft: #E6FAF8;
    --sd-success-soft: #D8F3DC;
    --sd-success-text: #2D6A4F;
    --sd-danger-soft: #FFF5F5;
    --sd-danger-text: #E63946;
    --sd-warning-soft: #FEF3C7;
    --sd-warning-text: #92400E;
    --sd-info-soft: #DBEAFE;
    --sd-info-text: #1E40AF;
    --sd-absence-soft: #EDE9FE;
    --sd-absence-text: #5B21B6;
}
html[data-theme="dark"] {
    --sd-surface: #1E1E1E;
    --sd-bg-subtle: #181818;
    --sd-border: #2D2D2D;
    --sd-text: #E6E6E6;
    --sd-text-secondary: #B0B0B0;
    --sd-text-muted: #8A8A8A;
    --sd-accent-soft: #0E2E2B;
    --sd-success-soft: #16341F;
    --sd-success-text: #5FD98A;
    --sd-danger-soft: #3A1C1F;
    --sd-danger-text: #F5808B;
    --sd-warning-soft: #3A2E10;
    --sd-warning-text: #FCD34D;
    --sd-info-soft: #1E2A47;
    --sd-info-text: #93C5FD;
    --sd-absence-soft: #2E2547;
    --sd-absence-text: #C4B5FD;
}

html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
}

h1:focus { outline: none; }

/* ─── Sidebar ─────────────────────────── */
.sidebar-drawer {
    border-right: 1px solid var(--sd-border) !important;
}

.sidebar-brand { border-bottom: none; }

.nav-group-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--sd-text-muted);
    padding: 0 16px;
    margin-top: 8px;
    margin-bottom: 4px;
}

/* ─── Mobile bottom nav ───────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 56px;
    border-top: 1px solid var(--sd-border) !important;
    background: var(--sd-surface);
    border-radius: 0 !important;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner { width: 100%; height: 100%; padding: 4px 0; }
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.65rem;
    color: #6C757D;
    text-decoration: none;
    padding: 4px 12px;
    min-width: 48px;
    min-height: 48px;
    justify-content: center;
    transition: color 0.15s;
}
.bottom-nav-item:hover { color: #00B5A6; }
.bottom-nav-item--active,
.bottom-nav-item--active:hover { color: #00B5A6; font-weight: 600; }

/* ─── Main content ────────────────────── */
.main-content {
    padding-bottom: calc(56px + env(safe-area-inset-bottom) + 16px);
}
@media (min-width: 960px) {
    .main-content { padding-bottom: 0; }
}

/* ─── Cards ───────────────────────────── */
.stat-card {
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    padding: 20px;
    background: var(--sd-surface);
}

.section-card {
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    padding: 20px;
    background: var(--sd-surface);
}

/* ─── Notification bell ───────────────── */
.notification-bell { position: relative; }
.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #E63946;
}

/* ─── Sync status ─────────────────────── */
.sync-indicator {
    font-size: 0.7rem;
    color: var(--sd-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 16px;
    margin-bottom: 8px;
}

/* ─── Context switcher ────────────────── */
.context-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.context-switcher:hover { background: var(--sd-bg-subtle); }

/* ─── Forefallende kanban ─────────────── */
.kanban-card {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--sd-surface);
}
.kanban-card--overdue { border-left: 3px solid #E63946; }
.kanban-card--thisweek { border-left: 3px solid #F4A261; }
.kanban-card--thismonth { border: 1px solid var(--sd-border); }
.kanban-card--later { border: 1px solid var(--sd-border); }

/* ─── Week view ───────────────────────── */
.week-day-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sd-text-secondary);
    text-transform: uppercase;
    padding: 8px 0;
    border-bottom: 1px solid var(--sd-border);
}
.week-day-header--today {
    color: #00B5A6;
    border-bottom: 2px solid #00B5A6;
}

/* ─── Status badges ───────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 12px;
}
.status-badge--open { background: #FEE2E2; color: #DC2626; }
.status-badge--inprogress { background: #FEF3C7; color: #D97706; }
.status-badge--closed { background: #D1FAE5; color: #059669; }
.status-badge--draft { background: #F3F4F6; color: #6B7280; }
.status-badge--submitted { background: #DBEAFE; color: #2563EB; }
.status-badge--approved { background: #D1FAE5; color: #059669; }
.status-badge--rejected { background: #FEE2E2; color: #DC2626; }

/* ─── Risk matrix ─────────────────────── */
.risk-cell {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 6px;
}
.risk-low { background: #D1FAE5; color: #059669; }
.risk-medium { background: #FEF3C7; color: #D97706; }
.risk-high { background: #FED7AA; color: #C2410C; }
.risk-critical { background: #FEE2E2; color: #DC2626; }

/* ─── Cert badges ─────────────────────── */
.cert-ok { color: #059669; }
.cert-expiring { color: #D97706; }
.cert-expired { color: #DC2626; }

/* ─── Blazor error ────────────────────── */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}
.blazor-error-boundary::after { content: "En feil har oppstatt." }

/* ─── Wizard steps ────────────────────── */
.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #6C757D;
}
.wizard-step--active { color: #00B5A6; font-weight: 600; background: #EEF2FF; }
.wizard-step--completed { color: #059669; }

/* ─── Shepherd Tour ──────────────────── */
.shepherd-element {
    font-family: 'Inter', sans-serif !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12) !important;
}
.shepherd-header {
    padding: 16px 16px 0 !important;
    background: transparent !important;
}
.shepherd-title {
    font-weight: 700 !important;
    font-size: 1rem !important;
    color: #1B2A4A !important;
}
.shepherd-text {
    padding: 8px 16px 16px !important;
    font-size: 0.9rem !important;
    color: #6B7280 !important;
    line-height: 1.5 !important;
}
.shepherd-footer {
    padding: 0 16px 16px !important;
}
.shepherd-button-primary {
    background: #00B5A6 !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    text-transform: none !important;
}
.shepherd-button-secondary {
    background: transparent !important;
    color: #6B7280 !important;
    text-transform: none !important;
}

/* ─── Responsive helpers ──────────────── */
.touch-target { min-width: 48px; min-height: 48px; }

/* ─── Settings (Innstillinger) ────────────
   Mobile-first: hub list → section detail.
   Desktop ≥960px: persistent left rail + content (per admin-settings spec). */
.settings-layout {
    display: block;
    animation: settings-fade-in 0.18s ease-out;
}
@keyframes settings-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

/* Rail doubles as the mobile hub */
.settings-rail { min-width: 0; }
.settings-content { min-width: 0; }

/* Mobile: show either hub or section, never both */
.settings-layout:not(.has-section) .settings-content { display: none; }
.settings-layout.has-section .settings-rail { display: none; }

.settings-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sd-text-muted);
    margin: 20px 4px 8px;
}
.settings-group-label:first-of-type { margin-top: 12px; }

.settings-group-card {
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    background: var(--sd-surface);
    overflow: hidden;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-height: 56px;
    cursor: pointer;
    text-decoration: none;
    color: var(--sd-text);
    transition: background 0.15s;
    border-bottom: 1px solid var(--sd-border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: var(--sd-bg-subtle); }
.settings-row--active {
    background: var(--sd-accent-soft);
    box-shadow: inset 3px 0 0 #00B5A6;
}
.settings-row--active:hover { background: var(--sd-accent-soft); }

.settings-row-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sd-bg-subtle);
    color: #00B5A6;
}
.settings-row--active .settings-row-icon { background: var(--sd-surface); }

.settings-row-text { flex: 1; min-width: 0; }
.settings-row-title { font-size: 0.9rem; font-weight: 600; line-height: 1.3; }
.settings-row-desc {
    font-size: 0.75rem;
    color: var(--sd-text-secondary);
    line-height: 1.35;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.settings-row-match {
    font-size: 0.75rem;
    color: #00B5A6;
    font-weight: 500;
    margin-top: 1px;
}
.settings-row-chevron { flex-shrink: 0; color: var(--sd-text-muted); display: flex; }

/* Section detail */
.settings-section-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}
.settings-section-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sd-accent-soft);
    color: #00B5A6;
}

/* Setting row inside section cards: label/description left, control right */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--sd-border); }
.setting-row-text { flex: 1; min-width: 0; }
.setting-row-control { flex-shrink: 0; }

/* Desktop: persistent rail + content */
@media (min-width: 960px) {
    .settings-layout,
    .settings-layout.has-section {
        display: grid;
        grid-template-columns: 296px minmax(0, 1fr);
        gap: 24px;
        align-items: start;
    }
    .settings-layout:not(.has-section) .settings-content,
    .settings-layout.has-section .settings-rail { display: block; }

    .settings-rail {
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 96px);
        overflow-y: auto;
        padding-right: 4px;
    }
    /* Compact rail on desktop: hide row descriptions and chevrons */
    .settings-rail .settings-row-desc { display: none; }
    .settings-rail .settings-row-chevron { display: none; }
    .settings-rail .settings-row { min-height: 44px; padding: 10px 12px; }
    .settings-rail .settings-row-icon { width: 32px; height: 32px; }
    /* Search results keep their match captions visible */
    .settings-rail .settings-row-match { display: block; }
}
