/* ===========================================
   Project overview: the customizable card grid
   Rows of thirds in the viewer's layout (botterino/web/overview_layout.py), the cards
   in projects/overview_cards/, chart cards (Sentiment / Actions Breakdown) and the
   "Customize overview" drawer. Built from primitives.css (.card-head, .kpis, .act-tag,
   .state, .rule-text, .row-menu ...); this file only lays them out.

   Shared beyond the overview (keep): .ov-kpi* tiles, .actions-bar / .actions-legend,
   .ov-chart-hero / -score / -caption / -delta / -split / -plot, .quiet-note, .ov-tip*.
   =========================================== */

/* Header: title + status left, Customize + range right; the controls drop under the
   title when the row runs out of room. */
.overview-head { margin-bottom: var(--gap); align-items: flex-start; }
.overview-head .page-title { flex-wrap: wrap; }
.overview-title-name { min-width: 0; overflow-wrap: anywhere; }
.overview-controls { align-items: stretch; flex-wrap: nowrap; }
.overview-live { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.overview-live .act-tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }

/* Phones: the picker's parts join the row (Customize beside the tabs, same height). */
@media (max-width: 768px) {
    .overview-controls { flex: 1 1 100%; margin-left: 0; flex-wrap: wrap; row-gap: 4px; }
    .overview-controls .range-picker { display: contents; }
}

.overview-customize-btn { height: auto; min-height: 30px; gap: 6px; white-space: nowrap; }
.overview-customize-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }

/* === Grid: S / M / L = 2 / 4 / 6 of six columns (a third, two thirds, the row) === */
.ov-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--gap);
    align-items: stretch;
}

.ov-cell { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.ov-cell.ov-s { grid-column: span 2; }
.ov-cell.ov-m { grid-column: span 4; }
.ov-cell.ov-l { grid-column: 1 / -1; }

/* Cards fill their cell; in a stack the last card takes the leftover height. */
.ov-cell > .overview-card { display: flex; flex-direction: column; gap: 10px; flex: 0 0 auto; min-width: 0; }
.ov-cell > .overview-card:last-child { flex: 1 1 auto; }

/* Narrow desktops: a third gets too thin, so S pairs up in halves and M takes the row. */
@media (max-width: 1180px) {
    .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ov-cell.ov-s { grid-column: span 1; }
    .ov-cell.ov-m { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .ov-grid { grid-template-columns: minmax(0, 1fr); }
    .ov-cell.ov-s,
    .ov-cell.ov-m { grid-column: 1 / -1; }
}

/* === Rows inside a card (incidents, offenders, people): hairline between rows === */
.ov-rows { display: flex; flex-direction: column; }
.ov-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; min-width: 0; }
.ov-row + .ov-row { border-top: 1px solid var(--hairline); }
.ov-row > .avatar, .ov-row > img.avatar { margin-top: 1px; }
.ov-grid img.avatar { object-fit: cover; padding: 0; }
.ov-row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ov-row-top { display: flex; align-items: baseline; flex-wrap: wrap; row-gap: 2px; }
.ov-name { margin-right: 8px; color: var(--label-1); font-size: 14px; font-weight: 600; text-decoration: none; }
a.ov-name:hover { text-decoration: underline; color: var(--label-1); }
.ov-name .name-handle { font-weight: 400; font-size: 12.5px; color: var(--label-3); }
.ov-row-top a.when { text-decoration: none; }
.ov-row-top a.when:hover { color: var(--label-1); }
/* Recent incidents: the hover toolbar (.row-tools, primitives.css) floats in the row's corner;
   on touch screens its More button takes a slot of its own. */
.ov-inc .row-tools { top: 8px; right: 0; }
.ov-inc .ov-row-side { display: flex; align-items: flex-end; align-self: stretch; flex-shrink: 0; }
@media (hover: none) { .ov-row-side { flex-shrink: 0; } }
.ov-inc .inc-quote { max-width: 100%; }

/* === Key numbers === */
.ov-kpis .kpi { text-decoration: none; }
.ov-kpis .kpi-value.pos { color: var(--green); }
.ov-kpis .kpi-value.neg { color: var(--red); }
.ov-kpis .micro { display: inline-flex; align-items: center; gap: 5px; }
.ov-kpis .kpi-spark { bottom: auto; top: 46px; }
.ov-mood-bar { margin-top: 4px; }
.ov-mood-bar i { border-radius: 2px; }
.ov-mood-bar .m-pos { background: var(--green); }
.ov-mood-bar .m-neu { background: var(--dv-volume-2); }
.ov-mood-bar .m-neg { background: var(--red); }
.ov-kpis .ai-locked-line { margin: 0; text-align: left; }
/* Two by two below desktop width, phones included: four full-width tiles push the
   cards a whole screen down. */
@media (max-width: 1180px) {
    .kpis.ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .kpis.ov-kpis { gap: 10px; }
    .ov-kpis .kpi { padding: 12px 12px 13px; }
    .ov-kpis .kpi-value { font-size: 24px; }
    .ov-kpis .kpi-spark { display: none; }
}

/* === Needs you === */
.ov-needs-list { display: flex; flex-direction: column; }
.ov-need { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hairline); }
.ov-need b { display: block; color: var(--label-1); font-weight: 500; font-size: 14px; }
.ov-need-sub { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; font-size: 12.5px; color: var(--label-3); }
.ov-need-sub .dot { transform: translateY(-1px); }
.ov-need .btn { flex-shrink: 0; white-space: nowrap; }
.ov-needs-none { display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 0; border-top: 1px solid var(--hairline); font-size: 13.5px; color: var(--label-1); }
.ov-else { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hairline); }
.ov-else div { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--label-body); }

/* === The bot === */
.ov-kv { display: flex; align-items: center; gap: 8px; min-height: 26px; font-size: 13.5px; }
/* The label grows, so a toggle (whose margins toggles.css pins) lands on the right. */
.ov-kv > :first-child { flex: 1 1 auto; min-width: 0; color: var(--label-2); display: inline-flex; align-items: center; gap: 5px; }
.ov-kv > :last-child { margin-left: auto; color: var(--label-1); font-weight: 500; text-align: right; }
.ov-kv > .toggle-switch { font-weight: 400; }
.ov-kv.quick-toggle-locked > :first-child { opacity: 0.6; }
.ov-bot .quick-toggles { gap: 0; }
.ov-bot-section { padding-top: 10px; border-top: 1px solid var(--hairline); }
.ov-bot-warning { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: 13px; color: var(--label-body); }

/* === What they talk about === */
.ov-topic-list { display: flex; flex-direction: column; }
.ov-topic { display: grid; grid-template-columns: 72px minmax(0, 1fr) 36px; align-items: center; gap: 12px; padding: 5px 0; font-size: 13.5px; color: var(--label-1); }
.ov-topic-track { height: 3px; border-radius: 2px; background: var(--fill-2); overflow: hidden; }
.ov-topic-track i { display: block; height: 100%; background: var(--label-2); }
.ov-topic-track i.hl { background: var(--accent); }
.ov-topic-pct { text-align: right; color: var(--label-2); }
.ov-topic-note { margin: 0; }

/* === People of the week === */
.ov-people-list { display: flex; flex-direction: column; }
.ov-person { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-width: 0; }
.ov-person + .ov-person { border-top: 1px solid var(--hairline); }
.ov-person-top { display: flex; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.ov-person-top .ov-name { margin-right: 6px; }
.ov-person-why { font-size: 12.5px; color: var(--label-3); text-decoration: none; }
.ov-person-why::before { content: '·'; margin-right: 6px; }
.ov-person-why:hover { color: var(--label-1); }
.ov-person-line { display: flex; align-items: baseline; min-width: 0; font-size: 12.5px; color: var(--label-2); white-space: nowrap; }
.ov-person-quote { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ov-person-line > :not(.ov-person-quote) { flex-shrink: 0; }

/* === Recent chat === */
.ov-chat .card-head .ov-live { margin-left: auto; }
.ov-chat .card-head .ov-live + .link { margin-left: 12px; }
.ov-chat .msg-list { min-width: 0; }

/* === Top offenders === */
.ov-offender { align-items: center; padding: 10px 0; }
.ov-rank { width: 14px; flex-shrink: 0; color: var(--label-3); font-size: 12.5px; text-align: center; }
.ov-offender .grow .ov-name { display: block; }
.ov-offender-count { font-size: 12.5px; color: var(--label-2); }
.ov-offender-count b { color: var(--label-1); font-weight: 500; }

/* === Key-number tiles shared with other pages (.ov-kpi) === */
.ov-kpi-value { font-size: 26px; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; color: var(--label-1); font-variant-numeric: tabular-nums; }
.ov-kpi-value.success { color: var(--green); }
.ov-kpi-value.warning { color: var(--amber); }

/* === Actions breakdown (Actions card, other pages' stats) === */
.actions-bar { display: flex; gap: 2px; height: 6px; margin: 6px 0; border-radius: 3px; overflow: hidden; background: var(--fill-2); }
.actions-bar i { display: block; height: 100%; min-width: 3px; }
.actions-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; color: var(--label-2); }
.actions-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.actions-legend b { font-weight: 500; color: var(--label-1); font-variant-numeric: tabular-nums; }
.actions-legend i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.actions-bar .deleted, .actions-legend .deleted, .ov-chart-split i.deleted { background: var(--act-deleted); }
.actions-bar .muted, .actions-legend .muted, .ov-chart-split i.muted { background: var(--act-muted); }
.actions-bar .banned, .actions-legend .banned, .ov-chart-split i.banned { background: var(--act-banned); }
.actions-card .ov-kpi-value { font-size: 26px; }

/* === Chart cards: Sentiment Breakdown and Actions Breakdown === */
/* Header right side: Mood / Actions toggle + page link. */
.ov-card-tools { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ov-chart-hero { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.ov-chart-score { font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--label-1); }
.ov-chart-score.positive { color: var(--green); }
.ov-chart-score.negative { color: var(--red); }
.ov-chart-caption { display: flex; flex-direction: column; font-size: 12.5px; line-height: 1.35; color: var(--label-2); }
.ov-chart-delta { align-self: center; padding: 2px 8px; border-radius: var(--r-sm); background: var(--fill-1); font-size: 12px; font-weight: 500; color: var(--label-2); white-space: nowrap; }
.ov-chart-delta.good { background: var(--green-tint); color: var(--green); }
.ov-chart-delta.bad { background: var(--red-tint); color: var(--red); }
.ov-chart-split { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--label-2); }
.ov-chart-split span { display: inline-flex; align-items: center; gap: 6px; }
.ov-chart-split b { font-weight: 500; color: var(--label-1); font-variant-numeric: tabular-nums; }
.ov-chart-split i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ov-chart-split i.positive { background: var(--green); }
.ov-chart-split i.neutral { background: var(--dv-volume); }
.ov-chart-split i.negative { background: var(--red); }

/* Grows with the card when a taller neighbour stretches the row. */
.ov-chart-plot { flex: 1 1 240px; min-height: 240px; }

.quiet-note { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px dashed var(--hairline); border-radius: var(--r-md); background: var(--fill-1); font-size: 13px; color: var(--label-2); }
.quiet-note b { font-weight: 500; color: var(--label-1); }
.quiet-note svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: var(--label-3); stroke-width: 2; }

/* Chart tooltip (built by js/overview_charts.js inside the ECharts tooltip box) */
.ov-tip { min-width: 170px; padding: 8px 10px; font-size: 13px; color: var(--label-1); }
.ov-tip-day { font-size: 12px; color: var(--label-2); margin-bottom: 6px; }
.ov-tip-empty { color: var(--label-3); }
.ov-tip-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ov-tip-row span { display: inline-flex; align-items: center; gap: 6px; color: var(--label-2); }
.ov-tip-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ov-tip-row b { font-weight: 500; font-variant-numeric: tabular-nums; }
.ov-tip-sep { border-top: 1px solid var(--hairline); margin-top: 6px; padding-top: 6px; }

/* Empty / locked card stretched by a taller neighbour: centre its one line. */
.ov-cell > .overview-card > .empty-state-text:last-child,
.ov-cell > .overview-card > .ai-locked-line:last-child { margin: auto; }

/* === Customize drawer === */
.customize-drawer {
    margin: 0 0 0 auto;
    height: 100vh;
    max-height: 100vh;
    width: min(480px, 100vw);
    max-width: 100vw;
    padding: 0;
    border: none;
    border-left: 1px solid var(--hairline);
    background: var(--surface-1);
    color: var(--label-1);
    box-shadow: var(--shadow-float);
}
.customize-drawer[open] { display: flex; flex-direction: column; }
/* Light backdrop: layout changes apply at once and should be visible behind the drawer. */
.customize-drawer::backdrop { background: color-mix(in srgb, var(--overlay-bg) 35%, transparent); }
.customize-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--hairline); }
.customize-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.customize-close { padding: 0; border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--label-2); }
.customize-close:hover { color: var(--label-1); }
.customize-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.customize-section { font: 500 11px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--label-3); }
.customize-section small { font-family: var(--font); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.customize-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.customize-preset {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    padding: 10px;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: var(--label-1);
    background: var(--fill-1);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
}
.customize-preset:hover { background: var(--fill-2); }
.customize-preset.on { background: var(--sel-bg); border-color: var(--sel-line); }
.customize-preset b { font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.customize-preset small { font-size: 12px; color: var(--label-2); line-height: 1.35; }

/* Mini map of the preset: one block per grid cell, sized like the cell (sixths) */
.preset-thumb { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 12px; gap: 3px; }
.preset-thumb i { grid-column: span 2; background: var(--fill-2); border-radius: 3px; }
.preset-thumb i.ov-m { grid-column: span 4; }
.preset-thumb i.ov-l { grid-column: 1 / -1; height: 7px; align-self: center; }
.preset-thumb i.stacked { background: linear-gradient(var(--fill-2) 45%, transparent 45%, transparent 55%, var(--fill-2) 55%); }
.customize-preset.on .preset-thumb i { background-color: var(--dv-volume-2); }

.customize-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.customize-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--fill-1); border: 1px solid var(--hairline); border-radius: var(--r-md); }
.customize-row.off { opacity: 0.55; }
.customize-row.dragging { opacity: 0.4; border-style: dashed; }
.customize-grip { color: var(--label-3); letter-spacing: -2px; cursor: grab; user-select: none; }
.customize-row-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.customize-row-text b { font-size: 13.5px; font-weight: 500; }
.customize-row-text small { font-size: 12px; color: var(--label-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.customize-stack,
.customize-sizes button {
    flex-shrink: 0;
    height: 24px;
    min-width: 24px;
    padding: 0 6px;
    font: 500 12px var(--font);
    line-height: 1;
    cursor: pointer;
    color: var(--label-3);
    background: transparent;
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
}
.customize-stack.on,
.customize-sizes button.on { color: var(--label-1); background: var(--sel-bg); border-color: var(--sel-line); }
.customize-sizes { display: inline-flex; gap: 2px; flex-shrink: 0; }
.customize-sizes.single { width: 0; }
.customize-row .toggle-switch { flex-shrink: 0; }
.customize-note { margin: 0; font-size: 12.5px; color: var(--label-3); }
.customize-foot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--hairline); }
.customize-foot .btn-primary { margin-left: auto; }
