/*
 * Retail Analytics Dashboard
 * Design nach Otl Aicher: Reduktion · Systematik · Funktion
 * Grid: 8px · Farben: #1a1a1a + #E87722 (Akzent) · Graustufen
 */

:root {
    --ink:      #1a1a1a;
    --ink-2:    #444444;
    --ink-3:    #777777;
    --ink-4:    #aaaaaa;
    --line:     #e0e0e0;
    --bg:       #f8f8f6;
    --white:    #ffffff;
    --orange:   #E87722;
    --red:      #B91C1C;
    --green:    #166534;

    --font: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --max: 1600px;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

/* ─── HEADER ─────────────────────────────────────────────── */

.dashboard-header {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 20px 0 14px;
}

.header-inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.dashboard-header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-bottom: 2px;
}

.dashboard-header p {
    font-size: 0.75rem;
    color: var(--ink-3);
    font-weight: 400;
}

.header-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.meta-item {
    font-size: 0.6875rem;
    color: var(--ink-4);
    font-weight: 400;
}

.meta-sep { color: var(--line); }

/* ─── CONTENT ────────────────────────────────────────────── */

.content {
    max-width: var(--max);
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ─── KPI-LEISTE ─────────────────────────────────────────── */

.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    padding: 20px 24px;
    border: 1px solid var(--line);
    background: var(--white);
    display: flex;
    flex-direction: column;
    position: relative;
}

.kpi-chart-area {
    flex: 0 0 80px;
    min-height: 80px;
    margin: 8px 0;
    display: flex;
    align-items: center;
}

.kpi-chart-area > * { width: 100%; }
.kpi-sub { margin-top: auto; }

.kpi-label {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-4);
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 2.125rem;
    font-weight: 300;
    letter-spacing: -0.03em;
    color: var(--ink);
    line-height: 1;
}

.kpi-sub {
    font-size: 0.875rem;
    color: var(--ink-3);
    line-height: 1.4;
    margin-top: 2px;
}

/* ─── BEFUND-BANNER ──────────────────────────────────────── */

.insight-banner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1px solid var(--line);
    border-left: 3px solid var(--orange);
    background: var(--white);
    margin-bottom: 16px;
    overflow: hidden;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 24px;
    border-right: 1px solid var(--line);
}

.insight-item:last-child { border-right: none; }

.insight-num {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--orange);
    line-height: 1;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

.insight-body { flex: 1; min-width: 0; }

.insight-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 5px;
    line-height: 1.3;
}

.insight-detail {
    font-size: 0.6875rem;
    color: var(--ink-3);
    line-height: 1.6;
}

/* ─── CHART-GRID ─────────────────────────────────────────── */

.chart-row { margin-bottom: 16px; }

.chart-row.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ─── CHART-CARD ─────────────────────────────────────────── */

.chart-card {
    background: var(--white);
    border: 1px solid var(--line);
    padding: 20px 24px 16px;
    position: relative;
}

.chart-header {
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

.chart-header h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.35;
    margin-bottom: 4px;
}

.chart-subtitle {
    font-size: 0.6875rem;
    color: var(--ink-3);
    line-height: 1.5;
    font-weight: 400;
}

/* ─── EXPAND BUTTON ──────────────────────────────────────── */

button[title="Vergrößern"] {
    /* Default: sichtbar auf Touch-Geräten, halbtransparent auf Desktop */
    opacity: 0.15;
    transition: opacity .15s ease, background .15s ease, color .15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 28px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hover (Desktop): volle Sichtbarkeit mit orangem Akzent */
.chart-card:hover button[title="Vergrößern"],
.kpi-card:hover button[title="Vergrößern"] {
    opacity: 1;
    color: var(--orange) !important;
}

button[title="Vergrößern"]:hover,
button[title="Vergrößern"]:focus {
    opacity: 1 !important;
    color: var(--orange) !important;
    outline: none;
}

button[title="Vergrößern"]:active {
    transform: scale(0.9);
}

/* Touch: immer gut sichtbar */
@media (hover: none) {
    button[title="Vergrößern"] {
        opacity: 0.6;
        color: var(--orange) !important;
        font-size: 16px !important;
    }
}

/* ─── FOOTER ─────────────────────────────────────────────── */

.dashboard-footer {
    max-width: var(--max);
    margin: 0 auto;
    padding: 16px 16px 32px;
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.6875rem;
    color: var(--ink-4);
    border-top: 1px solid var(--line);
}

/* ─── PLOTLY ─────────────────────────────────────────────── */

.modebar-container { display: none !important; }
.js-plotly-plot .plotly .main-svg { overflow: visible !important; }

/* ─── SCALE TOGGLE ───────────────────────────────────────── */

.scale-toggle .dash-radioitem label {
    display: inline-block;
    cursor: pointer;
    font-size: 10.5px;
    font-family: var(--font);
    letter-spacing: 0.04em;
    color: #999;
    padding: 2px 9px 3px;
    border: 1px solid #e4e4e4;
    border-radius: 2px;
    margin-left: 3px;
    user-select: none;
    transition: background .12s, color .12s, border-color .12s;
    background: #fafafa;
}

.scale-toggle .dash-radioitem label:hover {
    border-color: #bbb;
    color: #555;
    background: #f0f0f0;
}

.scale-toggle .dash-radioitem input[type="radio"]:checked ~ label,
.scale-toggle .dash-radioitem:has(input:checked) label {
    background: #1a1a1a;
    color: #fff !important;
    border-color: #1a1a1a;
}

/* ─── MODAL LESEHILFE ────────────────────────────────────────── */

#lesehilfe-text { line-height: 1.75; }
#modal-overlay  { transition: opacity .2s ease; }

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — Tablet (≤ 960px)
───────────────────────────────────────────────────────────── */

@media (max-width: 960px) {

    .header-inner  { padding: 0 12px; }
    .content       { padding: 16px 12px 32px; }

    /* KPI: 3 Spalten */
    .kpi-row {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Befund: 2 Spalten */
    .insight-banner {
        grid-template-columns: 1fr 1fr;
    }
    .insight-item:nth-child(2) { border-right: none; }
    .insight-item:nth-child(3) { border-top: 1px solid var(--line); }

    /* Charts: 1 Spalte */
    .chart-row.two-col {
        grid-template-columns: 1fr;
    }

    .kpi-value { font-size: 1.75rem; }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — Smartphone (≤ 600px)
───────────────────────────────────────────────────────────── */

@media (max-width: 600px) {

    html { font-size: 13px; }

    .header-inner  { padding: 0 10px; flex-direction: column; align-items: flex-start; }
    .header-meta   { display: none; }   /* zu eng auf kleinen Screens */
    .content       { padding: 12px 10px 24px; }

    /* KPI: 2 Spalten */
    .kpi-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .kpi-card      { padding: 14px 16px; }
    .kpi-value     { font-size: 1.5rem; }
    .kpi-label     { font-size: 0.6875rem; }
    .kpi-chart-area { flex: 0 0 40px; min-height: 40px; }

    /* Befund: 1 Spalte */
    .insight-banner {
        grid-template-columns: 1fr;
        border-left-width: 3px;
    }
    .insight-item {
        border-right: none;
        border-bottom: 1px solid var(--line);
        padding: 14px 16px;
        gap: 12px;
    }
    .insight-item:last-child { border-bottom: none; }
    .insight-num   { font-size: 1.125rem; }

    /* Charts 1 Spalte, weniger Padding */
    .chart-row.two-col { grid-template-columns: 1fr; gap: 10px; }
    .chart-card        { padding: 14px 12px 10px; }

    /* Modal: fast fullscreen */
    #modal-overlay > div {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        padding: 20px 16px !important;
        max-height: 100vh !important;
    }

    .dashboard-footer {
        padding: 12px 10px 20px;
        flex-wrap: wrap;
    }
}

@keyframes spin { to { transform: rotate(360deg); } }
