/* ============================================================================
   BAMS Core Admin - Redesign v3 (Sprint 25.aa)
   ============================================================================
   Erstatter admin/admin.css. Mørk navy sidebar (#021938 - BA brand) + hvid
   main area. Behold danske klassenavne (.knap, .knap-primary,
   .kort, .alert-fejl) - målrettet via CSS, ingen HTML/JS refactor.
   Reference: bams-redesign-v3.html (2296 linjer).
   ========================================================================== */

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

/* ==================== DESIGN TOKENS ==================== */
:root {
    /* Base */
    --bg: #ffffff;
    --bg-app: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #fafbfd;

    /* Text */
    --ink: #1a1f36;
    --ink-2: #2d3148;
    --ink-soft: #5b6178;
    --ink-mute: #8b91a8;
    --ink-faint: #c4c8d8;

    /* Lines */
    --line: #eaecf4;
    --line-soft: #f1f3f9;

    /* Primary - BA brand navy #021938 (navy-rebrand, match React-frontend tokens.css).
       Navy er næsten sort, så hover-lift går LYSERE (#1e3a5f) frem for mørkere. */
    --primary: #021938;
    --primary-dark: #1e3a5f;
    --primary-darker: #010f24;
    --primary-soft: #e3ebf4;
    --primary-faint: #f0f4f9;

    /* Sidebar specific - navy */
    --sb-bg: #021938;
    --sb-bg-2: #010f24;
    --sb-text: #b8c4d6;
    --sb-text-soft: #7f8ca3;
    --sb-active-bg: #1e3a5f;
    --sb-active-text: #ffffff;
    --sb-divider: #14283f;

    /* Status / chart colors */
    --green: #28c76f;
    --green-soft: #e3f7eb;
    --red: #ea5455;
    --red-soft: #fdecec;
    --amber: #ff9f43;
    --amber-soft: #fef0e0;
    --blue: #00cfe8;
    --blue-soft: #e0f8fb;
    --secondary: #ea7141;
    --secondary-soft: #fef0e8;

    /* Type */
    --font: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-ui: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    /* Shadow */
    --shadow-xs: 0 1px 2px rgba(26, 31, 54, 0.04);
    --shadow-sm: 0 2px 6px rgba(26, 31, 54, 0.05);
    --shadow-md: 0 4px 14px rgba(26, 31, 54, 0.07);
    --shadow-lg: 0 12px 28px rgba(26, 31, 54, 0.08);

    --r-sm: 6px;
    --r: 10px;
    --r-lg: 14px;
}

/* ==================== RESET ==================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg-app);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1 {
    font-family: var(--font);
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.1;
    margin: 0 0 8px 0;
}
h2 {
    font-family: var(--font);
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 12px 0;
}
h3 {
    font-family: var(--font);
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 8px 0;
}

.lead {
    color: var(--ink-soft);
    font-size: 15px;
    margin: 0 0 24px 0;
}

a { color: var(--primary); }

/* ==================== LAYOUT - APP SHELL ==================== */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    background: var(--sb-bg);
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    height: 64px;
    border-bottom: 1px solid var(--sb-divider);
    text-decoration: none;
}
.brand-logo {
    width: 28px; height: 28px;
    color: var(--secondary);
    display: flex; align-items: center; justify-content: center;
}
.brand-name {
    font-family: var(--font);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.02em;
    color: #fff;
}

.nav-label {
    font-size: 10px;
    color: var(--sb-text-soft);
    padding: 18px 22px 8px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    color: var(--sb-text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    position: relative;
}
.nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.04);
}
.nav-item.active {
    background: var(--sb-active-bg);
    color: var(--sb-active-text);
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--secondary);
}
.nav-item svg {
    width: 18px; height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}
.nav-item .badge {
    margin-left: auto;
    font-size: 10px;
    background: var(--secondary);
    color: #fff;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.nav-item .badge.new { background: var(--green); }

.nav-sub {
    display: none;
    flex-direction: column;
    background: var(--sb-bg-2);
    padding: 4px 0;
}
.nav-sub.open { display: flex; }
.nav-sub-item {
    padding: 8px 22px 8px 52px;
    color: var(--sb-text-soft);
    font-size: 13px;
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    font-family: inherit;
    transition: color 0.15s;
    text-decoration: none;
    display: block;
}
.nav-sub-item:hover { color: #fff; }
.nav-sub-item.active { color: #fff; font-weight: 600; }

/* ==================== MAIN AREA ==================== */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-app);
}

/* TOPBAR - kompatibel med eksisterende .topbar struktur (admin/admin.css) */
.topbar {
    padding: 0 40px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    justify-content: space-between;
}
.topbar-venstre { display: flex; align-items: center; gap: 16px; }
.bruger-navn {
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 500;
}
.breadcrumb {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: color 0.15s;
}
.breadcrumb:hover { color: var(--primary-dark); }
.log-ud {
    color: var(--red);
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: color 0.15s;
}
.log-ud:hover { color: #c33a3b; }

/* CONTENT - kompatibel med eksisterende .container.
   Sprint 25.aa fix 1: oeget horizontal padding fra 32px -> 56px for vejrtraekningsrum
   fra sidebar-kanten. Top/bottom svagt oeget for visuel ro. */
.content,
.container {
    padding: 36px 56px 60px;
    flex: 1;
    overflow-y: auto;
    max-width: 1320px;
    width: 100%;
}
.container.wide { max-width: 1520px; }

/* ==================== PAGE HEADER ==================== */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 24px;
}
.crumbs {
    font-size: 11px;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    margin-bottom: 8px;
}
.crumbs a { color: var(--ink-mute); text-decoration: none; }
.crumbs span { color: var(--ink); }
.crumb-sep { margin: 0 6px; opacity: 0.5; }

.page-title {
    font-family: var(--font);
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1;
}

/* ==================== CARDS - overrider eksisterende .card ==================== */
.card,
.kort {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.18s;
}
.card.interaktiv,
.kort.interaktiv {
    cursor: pointer;
}
.card.interaktiv:hover,
.kort.interaktiv:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 16px;
}
.card-header h3 {
    font-family: var(--font);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
}
.card-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    margin-top: 12px;
    display: inline-block;
    transition: color 0.12s;
}
.card-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* KPI cards (redesign-v3-style) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.kpi-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.18s;
}
.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* ==================== KNAPPER / BUTTONS ==================== */
/* Behold danske klasser (.knap, .knap-primary) + tilbyd nye (.btn) */

.knap,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
    transition: all 0.12s ease;
}
.knap:hover:not(:disabled),
.btn:hover:not(:disabled) {
    background: var(--surface-soft);
    border-color: var(--ink-faint);
}
.knap:active,
.btn:active { transform: translateY(1px); }
.knap:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.knap:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary variants */
.knap-primary,
.btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.knap-primary:hover:not(:disabled),
.btn.primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Sekundær (gray) */
.knap-sekundary,
.btn.sekundary {
    background: var(--ink-soft);
    color: #fff;
    border-color: var(--ink-soft);
}
.knap-sekundary:hover:not(:disabled),
.btn.sekundary:hover:not(:disabled) {
    background: var(--ink-2);
    border-color: var(--ink-2);
}

/* Fare (red) */
.knap-fare,
.btn.fare {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}
.knap-fare:hover:not(:disabled),
.btn.fare:hover:not(:disabled) {
    background: #c33a3b;
    border-color: #c33a3b;
}

/* Success (green) */
.knap-success,
.btn.success {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}
.knap-success:hover:not(:disabled),
.btn.success:hover:not(:disabled) { background: #21a05a; border-color: #21a05a; }

/* Ghost (transparent) */
.btn.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--primary);
}
.btn.ghost:hover:not(:disabled) {
    background: var(--primary-soft);
}

.knap-lille,
.btn.lille { padding: 6px 12px; font-size: 12px; }
.btn-large {
    width: 100%;
    padding: 13px;
    font-size: 14px;
    justify-content: center;
    font-weight: 700;
}

.knap svg,
.btn svg { width: 14px; height: 14px; }

/* ==================== FORMS ==================== */
label {
    display: block;
    font-size: 12px;
    color: var(--ink-soft);
    margin-bottom: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
select,
textarea,
.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    transition: all 0.15s;
}
input:focus,
select:focus,
textarea:focus,
.input-field:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-gruppe,
.input-group { margin-bottom: 18px; }

/* ==================== PILLS / BADGES ==================== */
.pill,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: var(--surface-soft);
    color: var(--ink-soft);
    letter-spacing: 0.02em;
}
.pill::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.pill.success { background: var(--green-soft); color: var(--green); }
.pill.warn    { background: var(--amber-soft); color: var(--amber); }
.pill.danger  { background: var(--red-soft); color: var(--red); }
.pill.info    { background: var(--blue-soft); color: var(--blue); }
.pill.primary-pill { background: var(--primary-soft); color: var(--primary); }
.pill.flat::before { display: none; }

/* ==================== TABELLER ==================== */
table,
.tabel-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--surface);
}
.tabel-wrapper {
    background: var(--surface);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
thead th {
    text-align: left;
    padding: 14px 20px;
    font-size: 11px;
    color: var(--ink-mute);
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
tbody td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--surface-soft); }

/* Klikbare rækker — hele rækken navigerer via onclick (fx bruger → detalje).
   Tydelig affordance: pointer-cursor over rækken (også over navnet) +
   navy-tonet hover-baggrund + navnet får link-look, så man kan se at man
   kan trykke ind på den. */
tbody tr.klikbar { cursor: pointer; }
tbody tr.klikbar:hover { background: var(--primary-faint); }
tbody tr.klikbar:hover strong { color: var(--primary); text-decoration: underline; }

/* ==================== ALERTS ==================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--r-sm);
    margin-bottom: 16px;
    font-size: 14px;
    border-left: 4px solid transparent;
}
.alert-info {
    background: var(--blue-soft);
    color: #0a8a9c;
    border-left-color: var(--blue);
}
.alert-fejl {
    background: var(--red-soft);
    color: #a83031;
    border-left-color: var(--red);
}
.alert-success {
    background: var(--green-soft);
    color: #1a8a4a;
    border-left-color: var(--green);
}
.alert-warning {
    background: var(--amber-soft);
    color: #b56812;
    border-left-color: var(--amber);
}

/* ==================== LOADER ==================== */
.loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== UTILITIES ==================== */
.skjult { display: none !important; }

.tom-tilstand {
    text-align: center;
    padding: 60px 24px;
    color: var(--ink-mute);
}
.tom-tilstand .ikon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.tom-tilstand p { margin: 8px 0; }

.row { display: flex; gap: 10px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; }
.mb-24 { margin-bottom: 24px; }
.mb-16 { margin-bottom: 16px; }
.mt-20 { margin-top: 20px; }
.col { display: flex; flex-direction: column; gap: 4px; }

/* ==================== TOPBAR EXTRAS (mobile/page-toolbar) ==================== */
.actions-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}
.tab {
    background: none;
    border: none;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink-mute);
    cursor: pointer;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.tab:hover { color: var(--ink); }

/* ==================== MATRICE TABEL (overrider gammelt) ==================== */
.matrice-tabel {
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    width: 100%;
}
.matrice-tabel thead th {
    background: var(--primary);
    color: #fff;
    border-bottom: none;
    text-transform: none;
    letter-spacing: normal;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 12px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}
.matrice-tabel thead .app-header {
    background: var(--primary-darker);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 14px;
}
.matrice-tabel thead .pakke-header {
    font-size: 11px;
    font-weight: 500;
    background: var(--primary);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.matrice-tabel tbody td {
    padding: 8px 12px;
    text-align: center;
    border-bottom: 1px solid var(--line-soft);
    border-right: 1px solid var(--line-soft);
}
.matrice-tabel tbody td.afd-navn {
    text-align: left;
    font-weight: 600;
    background: var(--surface-soft);
    color: var(--ink);
    border-right: 2px solid var(--line);
}
.matrice-tabel tbody td.aktiv-cell {
    background: var(--primary-faint);
    border-left: 2px solid var(--primary-soft);
}
.matrice-tabel tbody tr:hover td:not(.afd-navn) { background: var(--surface-soft); }
.matrice-tabel tbody tr:hover td.aktiv-cell { background: var(--primary-soft); }
.matrice-tabel input[type=checkbox] {
    width: 18px; height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}
.matrice-tabel input[type=checkbox]:disabled { cursor: not-allowed; opacity: 0.35; }
.matrice-tabel .ikke-tilgaengelig { color: var(--ink-faint); font-size: 18px; font-weight: bold; }

.legend {
    margin-top: 20px;
    padding: 14px 18px;
    background: var(--surface);
    border-radius: var(--r-lg);
    font-size: 13px;
    color: var(--ink-soft);
    box-shadow: var(--shadow-sm);
}
.legend strong { color: var(--primary); }
.legend-item { display: inline-block; margin-right: 16px; }

/* ==================== TOAST (besked) ==================== */
.besked {
    margin-top: 12px;
    font-size: 13px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
}
.besked.success { background: var(--green-soft); color: #1a8a4a; }
.besked.fejl { background: var(--red-soft); color: #a83031; }

/* ==================== MODAL (Sprint 25.aa fix 2) ====================
   Dialog-overlay brugt af .html + .js i 8 admin-sider (rapport-typer,
   customer-detalje, delivery-windows, inviter, matrice, scheduler,
   user-detalje, users). JS toggler display:none/flex paa .modal-overlay. */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 31, 54, 0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    animation: bamsModalFadeIn 0.15s ease-out;
}
.modal-overlay[style*="flex"] { display: flex !important; }
.modal-overlay.synlig { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    width: 100%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 32px 36px;
    animation: bamsModalSlideUp 0.2s ease-out;
}
.modal.bred { max-width: 760px; }
.modal.advarsel { border-top: 4px solid var(--red); }

.modal h3,
.modal h2 {
    font-family: var(--font);
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 16px;
    letter-spacing: -0.01em;
}
.modal .modal-besked {
    color: var(--ink-soft);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.55;
}

.modal-actions,
.modal-knap-rad {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

@keyframes bamsModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes bamsModalSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
