/* ============================================================
   Cronostoria e dashboard di wainow Lab (D533.5):
   Components/ConversationTimelineView.razor, OwnerDashboard.razor,
   TechnicianDashboard.razor, MetricChart.razor.

   Solo variabili del tema di wainow (css/wainow/): niente colori scritti a
   mano, cosi' tema chiaro e scuro si derivano da soli. I grafici sono
   DxChart con la tavolozza del tema DevExpress.
   ============================================================ */

.nl-dash {
    display: flex;
    flex-direction: column;
    gap: var(--wainow-space-5, 20px);
    font-family: var(--wainow-font-family, system-ui, sans-serif);
    color: var(--nx-text);
    padding-bottom: var(--wainow-space-8, 32px);
}

.nl-dash-header,
.nl-dash-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--wainow-space-3, 12px);
}

.nl-dash-heading { margin: 0; font-size: var(--wainow-fs-h2, 1.35rem); font-weight: 600; }
.nl-dash-sub, .nl-dash-hint, .nl-dash-muted, .nl-chart-note { color: var(--nx-text-muted); font-size: var(--wainow-fs-body-sm, .9rem); }
.nl-dash-hint { margin: 0 0 var(--wainow-space-2, 8px); }
.nl-dash-title { margin: 0 0 var(--wainow-space-2, 8px); font-size: var(--wainow-fs-h3, 1.1rem); font-weight: 600; }
.nl-dash-number { color: var(--nx-text-faint); }
/* «Le mie attività» (D535 L2): il titolo apre la scheda dell'attività, dove l'apertura si registra */
.nl-dash-link { color: var(--nx-corallo-ink); text-decoration: none; font-weight: var(--wainow-fw-semibold, 600); }
.nl-dash-link:hover, .nl-dash-link:focus-visible { text-decoration: underline; }
.nl-dash-section .nl-dash-sub { margin: 0 0 var(--wainow-space-2, 8px); }

.nl-dash-button,
.nl-period button {
    border: 1px solid var(--nx-line);
    background: var(--nx-surface);
    color: var(--nx-text);
    padding: 4px 14px;
    border-radius: var(--wainow-radius-md, 8px);
    font-size: var(--wainow-fs-body-sm, .9rem);
    cursor: pointer;
}
.nl-dash-button:hover:not(:disabled),
.nl-period button:hover { background: var(--nx-field-hover, var(--nx-field)); }
.nl-dash-button:disabled { opacity: .6; cursor: default; }

.nl-period { display: inline-flex; flex-wrap: wrap; max-width: 100%; gap: 2px; padding: 2px; border-radius: var(--wainow-radius-md, 8px); background: var(--nx-field); }
.nl-period button { border: 0; background: transparent; color: var(--nx-text-muted); }
.nl-period button.nl-active { background: var(--nx-surface); color: var(--nx-text); font-weight: 600; }

.nl-dash-notice {
    background: var(--nx-surface-alt, var(--nx-field));
    border: 1px solid var(--nx-line);
    border-left: 4px solid var(--nx-corallo);
    border-radius: var(--nx-radius-card, 12px);
    padding: var(--wainow-space-3, 12px) var(--wainow-space-4, 16px);
    line-height: 1.55;
    font-size: var(--wainow-fs-body-sm, .9rem);
}

.nl-dash-empty {
    color: var(--nx-text-muted);
    padding: var(--wainow-space-6, 24px);
    text-align: center;
}
.nl-dash-warning {
    background: var(--nx-warning-bg);
    color: var(--nx-warning-ink);
    border-radius: var(--wainow-radius-md, 8px);
    padding: var(--wainow-space-2, 8px) var(--wainow-space-3, 12px);
}

/* ---- totali ---- */
.nl-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
    gap: var(--wainow-space-3, 12px);
}
.nl-kpi {
    box-shadow: var(--nx-shadow-card, none);
    background: var(--nx-surface);
    border: 1px solid var(--nx-line);
    border-radius: var(--nx-radius-card, 12px);
    padding: var(--wainow-space-3, 12px) var(--wainow-space-4, 16px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.nl-kpi-label { color: var(--nx-text-muted); font-size: var(--wainow-fs-caption, .8rem); text-transform: none; }
.nl-kpi-value { font-size: var(--wainow-fs-kpi, 1.5rem); font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.nl-kpi-note { color: var(--nx-text-muted); font-size: var(--wainow-fs-caption, .8rem); }
.nl-meter { height: 6px; border-radius: 999px; background: var(--nx-field); overflow: hidden; margin-top: 4px; }
.nl-meter span { display: block; height: 100%; background: var(--nx-corallo); border-radius: 999px; }

/* ---- tabelle ---- */
.nl-table-wrap { overflow-x: auto; border: 1px solid var(--nx-line); border-radius: var(--nx-radius-card, 12px); background: var(--nx-surface); }
.nl-table { width: 100%; border-collapse: collapse; font-size: var(--wainow-fs-body-sm, .9rem); }
.nl-table th {
    text-align: left;
    font-weight: 600;
    font-size: var(--wainow-fs-table-head, .8rem);
    color: var(--nx-text-muted);
    background: var(--nx-surface-alt, var(--nx-field));
    padding: 8px 10px;
    border-bottom: 1px solid var(--nx-line);
    white-space: nowrap;
}
.nl-table td { padding: 7px 10px; border-bottom: 1px solid var(--nx-line-soft, var(--nx-line)); vertical-align: top; }
.nl-table tbody tr:last-child td { border-bottom: 0; }
.nl-table .nl-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nl-row-muted td { color: var(--nx-text-muted); }

/* ---- grafici ---- */
.nl-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
    gap: var(--wainow-space-4, 16px);
}
.nl-chart-card {
    box-shadow: var(--nx-shadow-card, none);
    background: var(--nx-surface);
    border: 1px solid var(--nx-line);
    border-radius: var(--nx-radius-card, 12px);
    padding: var(--wainow-space-3, 12px) var(--wainow-space-4, 16px);
    min-width: 0;
}
.nl-chart-head { display: flex; align-items: baseline; gap: var(--wainow-space-2, 8px); flex-wrap: wrap; margin-bottom: var(--wainow-space-2, 8px); }
.nl-chart-title { margin: 0; font-size: var(--wainow-fs-body, 1rem); font-weight: 600; }
.nl-chart-empty { padding: 60px var(--wainow-space-4, 16px); }
/* DxChart scrive in linea i colori di testi, assi e griglie presi al primo disegno (tema chiaro): qui li
   riportano le variabili del tema, cosi' il grafico si legge anche nel tema scuro e dopo un cambio a pagina
   aperta (provato il 19/11). Le serie restano nella tavolozza di DevExpress. */
.nl-chart svg text { fill: var(--nx-text-muted) !important; }
.nl-chart .dxc-legend svg text,
.nl-chart .dxc-legend text { fill: var(--nx-text) !important; }
.nl-chart .dxc-val-grid path,
.nl-chart .dxc-arg-grid path { stroke: var(--nx-line-soft, var(--nx-line)); }
.nl-chart .dxc-val-line path,
.nl-chart .dxc-arg-line path,
.nl-chart .dxc-arg-axis path,
.nl-chart .dxc-val-axis path { stroke: var(--nx-line); }
.nl-chart-tooltip { font-size: var(--wainow-fs-caption, .8rem); line-height: 1.4; }
.nl-chart-tooltip-series { font-weight: 600; }
.nl-chart-tooltip-time { color: var(--nx-text-muted); }
@media (width <= 560px) {
    .nl-charts { grid-template-columns: 1fr; }
    .nl-kpi-value { font-size: 1.25rem; }
    .nl-timeline-item { grid-template-columns: 92px 18px 1fr; }
    .nl-timeline-time { white-space: normal; }
    .nl-timeline-list::before { left: 108px; }
}

/* ---- cronostoria ---- */
.nl-timeline {
    font-family: var(--wainow-font-family, system-ui, sans-serif);
    color: var(--nx-text);
    /* dalla piu' recente in cima (19/11 sera): prende l'altezza della sua scheda e scorre dentro */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* la posizione di chi legge la tiene lo script (wainowLabTimeline), non il browser */
    overflow-anchor: none;
    position: relative;
    padding: 0 4px var(--wainow-space-2, 8px);
}
/* l'intestazione resta ferma in cima mentre la linea scorre */
.nl-timeline-head {
    position: sticky;
    top: 0;
    /* sopra i pallini (z-index 1) che scorrono sotto */
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--wainow-space-2, 8px) var(--wainow-space-3, 12px);
    padding: var(--wainow-space-2, 8px) 0;
    margin-bottom: var(--wainow-space-2, 8px);
    background: var(--nx-sheet);
}
.nl-timeline-head .nl-timeline-summary { margin-bottom: 0; }
.nl-timeline-new {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: var(--nx-pill, 999px);
    padding: 3px 12px;
    background: var(--nx-corallo);
    color: var(--nx-surface);
    font: inherit;
    font-size: var(--wainow-fs-caption, .8rem);
    font-weight: var(--wainow-fw-semibold, 600);
    cursor: pointer;
    box-shadow: var(--nx-shadow-float);
}
.nl-timeline-new:hover { background: var(--nx-corallo-hover); }
.nl-timeline-summary { color: var(--nx-text-muted); font-size: var(--wainow-fs-body-sm, .9rem); margin-bottom: var(--wainow-space-3, 12px); }
.nl-timeline-list { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.nl-timeline-list::before {
    content: "";
    position: absolute;
    /* al centro del pallino: 4 (rientro) + 132 (ora) + 4 (spazio) + 9 (meta' del pallino) - 1 */
    left: 148px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--nx-line);
}
.nl-timeline-item { display: grid; grid-template-columns: 132px 18px 1fr; align-items: start; gap: 4px; padding: 5px 0; }
.nl-timeline-time { grid-column: 1; color: var(--nx-text-muted); font-size: var(--wainow-fs-caption, .8rem); font-variant-numeric: tabular-nums; padding-top: 2px; text-align: right; padding-right: 6px; white-space: nowrap; }
.nl-timeline-dot {
    grid-column: 2;
    width: 10px;
    height: 10px;
    margin: 5px 0 0 4px;
    border-radius: 50%;
    background: var(--nx-text-faint);
    position: relative;
    z-index: 1;
    box-shadow: 0 0 0 3px var(--nx-surface);
}
.nl-timeline-body { grid-column: 3; min-width: 0; }
/* tutti sulla stessa riga della griglia: uno pseudo-elemento di un foglio comune non li spinge giu' */
.nl-timeline-time, .nl-timeline-dot, .nl-timeline-body { grid-row: 1; }
.nl-timeline-title { font-size: var(--wainow-fs-body-sm, .9rem); font-weight: 600; }
.nl-timeline-detail { font-size: var(--wainow-fs-caption, .8rem); color: var(--nx-text-muted); overflow-wrap: anywhere; }
.nl-tone-session .nl-timeline-dot { background: var(--nx-viola); }
.nl-tone-work .nl-timeline-dot { background: var(--nx-text-faint); }
.nl-tone-work .nl-timeline-title { font-weight: 500; }
.nl-tone-turn .nl-timeline-dot { background: var(--nx-corallo); }
.nl-tone-command .nl-timeline-dot { background: var(--nx-warning); }
.nl-tone-train .nl-timeline-dot { background: var(--nx-success); }
.nl-tone-error .nl-timeline-dot { background: var(--nx-danger); }
.nl-tone-error .nl-timeline-title { color: var(--nx-danger-ink); }


/* disco quasi pieno (90% e oltre): la barra passa al colore di avviso */
.nl-meter.nl-meter-warning span { background: var(--nx-warning); }

/* ---- spazio fra i gruppi di pulsanti e cio' che segue (19/11: «i pulsanti sono attaccati») ---- */
.nl-dash-title-row { margin-bottom: var(--wainow-space-4, 16px); }
.nl-dash-title-row .nl-dash-title { margin-bottom: 0; }
.nl-dash-header { margin-bottom: var(--wainow-space-1, 4px); }

/* ---- riquadri e grafici che si aprono verso la storia della metrica ---- */
.nl-kpi.nl-openable {
    position: relative;
    font: inherit;
    color: inherit;
    text-align: left;
    width: 100%;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.nl-kpi.nl-openable > span { display: block; }
.nl-kpi.nl-openable > .nl-meter { display: block; }
.nl-kpi.nl-openable > .nl-meter > span { display: block; }
.nl-openable:hover,
.nl-openable:focus-visible {
    border-color: var(--nx-corallo);
    box-shadow: var(--nx-shadow-float, var(--nx-shadow-card, none));
}
.nl-kpi.nl-openable:hover { transform: translateY(-1px); }
.nl-openable:focus-visible { outline: 2px solid var(--nx-focus, var(--nx-corallo)); outline-offset: 2px; }
.nl-open-chevron {
    position: absolute;
    top: var(--wainow-space-3, 12px);
    right: var(--wainow-space-3, 12px);
    color: var(--nx-text-faint);
    font-size: 1.25rem;
    line-height: 1;
}
.nl-openable:hover .nl-open-chevron { color: var(--nx-corallo-ink); }
.nl-chart-card.nl-openable { cursor: pointer; }
.nl-open-link {
    margin-left: auto;
    border: 1px solid var(--nx-line);
    background: var(--nx-surface);
    color: var(--nx-corallo-ink);
    border-radius: var(--nx-pill, 999px);
    padding: 2px 10px;
    font-size: var(--wainow-fs-caption, .8rem);
    font-weight: 600;
    cursor: pointer;
}
.nl-open-link:hover { background: var(--nx-field-hover, var(--nx-field)); }
.nl-chart-since { color: var(--nx-text-muted); font-size: var(--wainow-fs-caption, .8rem); margin-top: var(--wainow-space-1, 4px); }

/* ---- la storia di una metrica ---- */
.nl-detail { display: flex; flex-direction: column; gap: var(--wainow-space-4, 16px); }
.nl-back {
    border: 0;
    background: transparent;
    color: var(--nx-corallo-ink);
    font: inherit;
    font-weight: 600;
    padding: 0;
    margin-bottom: var(--wainow-space-1, 4px);
    cursor: pointer;
}
.nl-back:hover { text-decoration: underline; }
.nl-range {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--wainow-space-3, 12px) var(--wainow-space-5, 20px);
    padding: var(--wainow-space-3, 12px) var(--wainow-space-4, 16px);
    background: var(--nx-surface);
    border: 1px solid var(--nx-line);
    border-radius: var(--nx-radius-card, 12px);
}
.nl-range-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--wainow-space-2, 8px) var(--wainow-space-3, 12px); }
.nl-range-field { display: flex; flex-direction: column; gap: 2px; font-size: var(--wainow-fs-caption, .8rem); color: var(--nx-text-muted); }
.nl-range-date { min-width: 12rem; }
.nl-detail-stats { margin-bottom: 0; }
