/* ============================================================
   BI-mælaborð (greinenda-síða /dashboard) + admin SSO viðmót.
   Almenn skrá (tengd í App.razor) því verkefnið notar ekki
   Blazor CSS-isolation (styles.css bundle er ekki tengt).
   ============================================================ */

/* Sidebar-stíllinn er settur inline á mælaborðssíðunni (AnalystDashboard.razor),
   afritaður NÁKVÆMLEGA úr <style>-blokk Sidebar.razor — því þar býr raunverulegi
   sidebar-stíllinn (ekki í css-skrá). Þannig er mælaborðs-sidebar 100% eins. */

/* Aðalsvæði: enga hliðar-skrun, og loft í kringum efnið. */
.analyst-shell .main-content { min-width: 0; overflow-x: hidden; }
.analyst-shell .main-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.analyst-shell .main-header h1 { margin: 0; font-size: 1.4rem; }
.analyst-shell .main-header p { margin: 2px 0 0; color: #6b7280; font-size: 0.85rem; }
.analyst-shell .content-wrapper { padding: 2rem; }

/* Situr inni í portal .content-wrapper, svo engin heilsíðu-umgjörð hér. */
.dash {
    --c-primary: #2563eb;
    --c-margin: #10b981;
    --c-card: #ffffff;
    --c-border: #e5e7eb;
    --c-text: #1f2937;
    --c-muted: #6b7280;
    color: var(--c-text);
    max-width: 100%;
}

.dash-header-actions { display: flex; align-items: center; gap: 12px; }
.dash-warn { color: #b45309; font-size: 0.8rem; }

.dash-btn {
    background: var(--c-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background .15s;
}
.dash-btn:hover:not(:disabled) { background: #1d4ed8; }
.dash-btn:disabled { opacity: .6; cursor: default; }

/* Slicers */
.dash-slicers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 220px));
    gap: 12px;
    margin-bottom: 20px;
}
.dash .slicer { display: flex; flex-direction: column; gap: 4px; }
.dash .slicer label { font-size: 0.78rem; color: var(--c-muted); }
.dash .slicer select {
    width: 100%;
    padding: 8px 32px 8px 10px; /* hægra pláss fyrir chevron */
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background-color: #fff;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--c-text);
    cursor: pointer;
    /* eigin line-SVG chevron í stað native örvar */
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    transition: border-color .15s, box-shadow .15s;
}
.dash .slicer select:hover { border-color: #d1d5db; }
.dash .slicer select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* KPIs */
.dash-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.kpi {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 18px;
}
.kpi-label { font-size: 0.8rem; color: var(--c-muted); }
.kpi-value { font-size: 1.4rem; font-weight: 600; overflow-wrap: anywhere; }
.kpi-sub { font-size: 0.75rem; color: var(--c-muted); }

/* Cards */
.dash-card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 22px 24px;
    margin-bottom: 24px;
    overflow: hidden;
}
.dash-card h2 { font-size: 1.05rem; margin: 0 0 18px; }

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 24px;
}

/* Trend column chart */
.trend {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 220px;
    overflow-x: auto;
    padding-top: 8px;
}
.trend-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1 0 36px;
    height: 100%;
}
.trend-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 100%;
    width: 100%;
    justify-content: center;
}
.trend-bar { width: 10px; border-radius: 3px 3px 0 0; min-height: 2px; }
.trend-bar.sales { background: var(--c-primary); }
.trend-bar.margin { background: var(--c-margin); }
.trend-bar.lastyear { background: #cbd5e1; }
.trend-bar.forecast { background: #bfdbfe; border: 1px dashed #60a5fa; }
.trend-label { font-size: 0.68rem; color: var(--c-muted); margin-top: 6px; white-space: nowrap; }

.legend { display: flex; gap: 18px; margin-top: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--c-muted); }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.sales { background: var(--c-primary); }
.sw.margin { background: var(--c-margin); }
.sw.lastyear { background: #cbd5e1; }
.sw.forecast { background: #bfdbfe; border: 1px dashed #60a5fa; }

/* YoY tiles */
.dash-yoy { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }
.yoy-tile { background: var(--c-card); border: 1px solid var(--c-border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 3px; }
.yoy-label { font-size: 0.8rem; color: var(--c-muted); }
.yoy-value { font-size: 1.3rem; font-weight: 600; }
.yoy-change { font-size: 0.8rem; }
.yoy-change.up { color: #059669; }
.yoy-change.down { color: #dc2626; }

/* Notes / totals */
.dash-note { font-size: 0.8rem; color: var(--c-muted); margin: 0 0 12px; }
.dash-total { font-size: 0.85rem; margin-top: 12px; }
.dash-table .neg { color: #dc2626; }

/* Horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(70px, 130px) 1fr auto; align-items: center; gap: 10px; }
.hbar-name { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hbar-track { background: #f1f5f9; border-radius: 6px; height: 16px; overflow: hidden; min-width: 0; }
.hbar-fill { background: var(--c-primary); height: 100%; border-radius: 6px; }
.hbar-val { font-size: 0.8rem; text-align: right; color: var(--c-text); white-space: nowrap; }

/* Tables */
.dash-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dash-table th, .dash-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
}
.dash-table th { color: var(--c-muted); font-weight: 600; white-space: nowrap; }
.dash-table td.name { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-table .num { text-align: right; white-space: nowrap; }

/* States */
.dash-loading, .dash-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 80px 20px;
    color: var(--c-muted);
}
.dash-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: dash-spin 0.8s linear infinite;
}
@keyframes dash-spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
    .hbar-row { grid-template-columns: minmax(60px, 90px) 1fr auto; }
}

/* ============================================================
   Sjóðstreymis-mælaborð (/dashboard/sjodstreymi)
   Endurnýtir .dash-*, .kpi, .trend-bar, .hbar-*, .dash-table.
   ============================================================ */

/* Litir: innstreymi grænt, útstreymi coral, gjaldfallið dökkt, áætluð staða = primary lína. */
.dash {
    --c-inflow: #10b981;
    --c-outflow: #fb7185;
    --c-overdue: #b91c1c;
}
.trend-bar.inflow { background: var(--c-inflow); }
.trend-bar.outflow { background: var(--c-outflow); }
.hbar-fill.inflow { background: var(--c-inflow); }
.hbar-fill.outflow { background: var(--c-outflow); }
.hbar-fill.overdue { background: var(--c-overdue); }

.sw.inflow { background: var(--c-inflow); }
.sw.outflow { background: var(--c-outflow); }
.sw.balance { background: var(--c-primary); border-radius: 2px; height: 4px; align-self: center; }

.kpi-sub.up { color: #059669; }
.kpi-sub.down { color: #dc2626; }

/* Combo chart: súlur (inn/út) + áætluð-staða lína sem SVG-yfirlag. */
.cf-combo { display: flex; flex-direction: column; }
.cf-plot {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 220px;
    padding-top: 8px;
}
.cf-col {
    flex: 1 1 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 0;
}
.cf-col-bars { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.cf-line { position: absolute; inset: 8px 0 0 0; width: 100%; height: calc(100% - 8px); pointer-events: none; }
.cf-line polyline { fill: none; stroke: var(--c-primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.cf-labels { display: flex; gap: 10px; margin-top: 6px; }
.cf-label { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.cf-label-week { font-size: 0.7rem; color: var(--c-text); }
.cf-label-date { font-size: 0.68rem; color: var(--c-muted); white-space: nowrap; }

/* Samtala-lína í bankareikninga-töflu */
.dash-table tfoot td { border-top: 2px solid var(--c-border); border-bottom: none; padding-top: 12px; }

/* ============================================================
   Admin SSO viðmót (scope-að undir .sso-admin svo nöfn rekist
   ekki á admin.css)
   ============================================================ */

.sso-admin .sso-picker { display: flex; flex-direction: column; gap: 6px; max-width: 420px; margin-bottom: 20px; }
.sso-admin .sso-picker label { font-size: 0.85rem; color: #6b7280; }
.sso-admin .sso-picker select { padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.95rem; }

.sso-admin .sso-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 20px;
    max-width: 720px;
}
.sso-admin .sso-card h2 { font-size: 1.1rem; margin: 0 0 14px; }

.sso-admin .sso-state { margin: 0 0 14px; }
.sso-admin .sso-state .on { color: #059669; }
.sso-admin .sso-state .off { color: #9ca3af; }

.sso-admin .sso-field { margin-bottom: 16px; }
.sso-admin .sso-field label { display: block; font-size: 0.82rem; color: #6b7280; margin-bottom: 5px; }

.sso-admin .copy-row { display: flex; gap: 8px; }
.sso-admin .copy-row input {
    flex: 1;
    padding: 9px 11px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: Consolas, monospace;
    font-size: 0.88rem;
    background: #f9fafb;
}
.sso-admin .add-row { max-width: 480px; }
.sso-admin .add-row input { font-family: inherit; background: #fff; }

.sso-admin .sso-buttons { display: flex; gap: 10px; margin-top: 8px; }

.sso-admin .sso-primary, .sso-admin .sso-secondary, .sso-admin .sso-danger, .sso-admin .sso-copy {
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 0.9rem;
    cursor: pointer;
}
.sso-admin .sso-primary { background: #2563eb; color: #fff; }
.sso-admin .sso-primary:hover:not(:disabled) { background: #1d4ed8; }
.sso-admin .sso-secondary { background: #e5e7eb; color: #1f2937; }
.sso-admin .sso-secondary:hover:not(:disabled) { background: #d1d5db; }
.sso-admin .sso-danger { background: #fee2e2; color: #b91c1c; }
.sso-admin .sso-danger:hover:not(:disabled) { background: #fecaca; }
.sso-admin .sso-copy { background: #eff6ff; color: #2563eb; white-space: nowrap; }
.sso-admin .sso-copy:hover { background: #dbeafe; }
.sso-admin button:disabled { opacity: .6; cursor: default; }

.sso-admin .sso-link-danger { background: none; border: none; color: #b91c1c; cursor: pointer; font-size: 0.85rem; padding: 0; }
.sso-admin .sso-hint { font-size: 0.82rem; color: #6b7280; margin: 0 0 12px; }
.sso-admin .sso-hint.warn { color: #b45309; }

/* SSO staða + Mælaborð hlið við hlið (stafla á mjóum skjá) */
.sso-admin .sso-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.sso-admin .sso-row > .sso-card { flex: 1 1 340px; max-width: none; }

/* Mælaborða-toggles */
.sso-admin .dash-toggle-list { display: flex; flex-direction: column; gap: 4px; max-width: 480px; }
.sso-admin .dash-toggle-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid #f1f5f9; }
.sso-admin .dash-toggle-row:last-child { border-bottom: none; }
.sso-admin .dash-toggle-icon svg { width: 20px; height: 20px; color: #475569; display: block; }
.sso-admin .dash-toggle-name { flex: 1; font-size: 0.92rem; color: #1f2937; }
.sso-admin .dash-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.sso-admin .dash-switch input { opacity: 0; width: 0; height: 0; }
.sso-admin .dash-slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: background .15s; cursor: pointer; }
.sso-admin .dash-slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.sso-admin .dash-switch input:checked + .dash-slider { background: #2563eb; }
.sso-admin .dash-switch input:checked + .dash-slider::before { transform: translateX(18px); }
.sso-admin .dash-switch input:disabled + .dash-slider { opacity: .6; cursor: default; }
