/* Overview, the landing screen (overview.js) and its charts (charts.js).
   Cards, chips and the segmented control come from styles.css and
   components.css; colours only from tokens.css roles. */

#overview-body { transition: opacity .15s; }
#overview-body.is-refreshing { opacity: .55; pointer-events: none; }

.ov-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.ov-toolbar p { margin: 0; }
.seg.sm button { min-height: 30px; padding: 4px 12px; font-size: var(--typo-label-md); }

/* Getting started */
.ov-setup { margin-bottom: var(--space-5); border-color: color-mix(in srgb, var(--primary) 35%, var(--outline-variant)); }
.ov-setup-head, .ov-plan-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-2); }
:is(.ov-setup-head, .ov-plan-head) h3 { margin: 0; }
:is(.ov-setup-head, .ov-plan-head) p { margin: 2px 0 0; }
.ov-progress { flex: 0 1 200px; height: 8px; border-radius: var(--shape-full); background: linear-gradient(to right, var(--primary) var(--p), var(--surface-container-highest) 0); }
/* The bars fill from the reading start; none holds text, so Arabic simply mirrors them. */
html[dir="rtl"] :is(.ov-progress, .ov-paymix-bar, .ov-bar, .ov-plan-bar) { transform: scaleX(-1); }

/* Plan and this month's orders. Tone rides one class, so the border and the
   fill change together and `ok` says nothing in colour at all. The bar is the
   same one-element --p gradient as .ov-progress above; only the fill colour
   is a variable. */
.ov-plan { margin-bottom: var(--space-5); }
.ov-plan.is-near { --plan-fill: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, var(--outline-variant)); }
.ov-plan:is(.is-over, .is-blocked) { --plan-fill: var(--error); border-color: color-mix(in srgb, var(--error) 45%, var(--outline-variant)); }
.ov-plan-head { flex-wrap: wrap; gap: var(--space-3); }
.ov-plan-bar { height: 8px; margin-top: var(--space-3); border-radius: var(--shape-full);
               background: linear-gradient(to right, var(--plan-fill, var(--primary)) var(--p), var(--surface-container-highest) 0); }
.ov-plan-count { margin: var(--space-2) 0 0; font-size: var(--typo-label-md); }

/* What needs doing */
.ov-tasks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.ov-task {
    display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
    border-radius: var(--shape-lg); background: var(--card); border: 1px solid var(--outline-variant);
    color: var(--on-surface); text-decoration: none; min-height: var(--min-touch-target); transition: border-color .15s, background .15s;
}
.ov-task:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--card)); }
.ov-task-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--shape-full); background: var(--warning-container); color: var(--on-warning-container); }
.ov-task-text { flex: 1; min-width: 0; }
.ov-task-text strong { font-family: var(--font-headline); font-size: var(--typo-title-md); }
.ov-task-go { color: var(--on-surface-variant); display: flex; }
html[dir="rtl"] .ov-task-go svg { transform: scaleX(-1); }
.ov-caught-up {
    display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-4); padding: var(--space-2) var(--space-4);
    border-radius: var(--shape-full); background: var(--success-container); color: var(--on-success-container); width: fit-content; max-width: 100%;
}

/* Headline numbers */
.ov-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.ov-kpi {
    position: relative; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; overflow: hidden;
    padding: var(--space-4) var(--space-4) 44px; border-radius: var(--shape-lg);
    background: var(--card); border: 1px solid var(--outline-variant);
}
.ov-kpi-label { font-size: var(--typo-label-lg); color: var(--on-surface-variant); }
.ov-kpi-value { font-family: var(--font-headline); font-size: var(--typo-headline-sm); line-height: var(--typo-headline-sm-lh); font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ov-kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); font-size: var(--typo-body-sm); position: relative; z-index: 1; }
.ov-kpi .spark { position: absolute; inset-inline: 0; bottom: 0; width: 100%; height: 34px; opacity: .9; }
.ov-delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; padding: 1px 6px; border-radius: var(--shape-full); background: var(--surface-container-high); color: var(--on-surface-variant); }
.ov-delta.up { background: var(--success-container); color: var(--on-success-container); }
.ov-delta.down { background: var(--error-container); color: var(--on-error-container); }
.spark-line { fill: none; stroke: var(--primary); stroke-width: 1.5; stroke-linejoin: round; }
.spark-area { fill: color-mix(in srgb, var(--primary) 10%, transparent); }

/* Cards */
.ov-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.ov-grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.ov-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.ov-card-head h3 { margin: 0; }
.ov-more { font-size: var(--typo-label-lg); font-weight: 500; white-space: nowrap; }
.ov-none { margin: var(--space-2) 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--primary); margin-inline-end: 6px; vertical-align: baseline; flex: none; }
.swatch.prev { background: none; border-top: 2px dashed var(--outline); border-radius: 0; height: 0; width: 14px; vertical-align: middle; }
.swatch.pay-cod { background: var(--chart-5); }
.swatch.pay-card { background: var(--chart-1); }

/* Trend */
.ov-trend { position: relative; min-width: 0; display: flex; flex-direction: column; }
.ov-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: 4px 0 0; font-size: var(--typo-body-sm); color: var(--on-surface-variant); }
.ov-chart { flex: 1; min-height: 240px; }
.ov-chart-empty {
    position: absolute; inset: 72px var(--space-4) 48px; display: grid; place-content: center; text-align: center; padding: var(--space-4);
    background: color-mix(in srgb, var(--card) 82%, transparent);
}
.ov-chart-empty p { margin: 2px 0; max-width: 42ch; margin-inline: auto; }
.ov-share { display: flex; justify-content: center; gap: var(--space-2); margin-top: var(--space-3) !important; }

.chart { display: flex; flex-direction: column; height: 100%; }
.chart-plot { position: relative; flex: 1; margin-top: var(--space-4); touch-action: pan-y; }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: var(--outline-variant); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-base { stroke: var(--outline-variant); stroke-width: 1; }
/* In CSS, not stop-color="": a presentation attribute does not resolve var(). */
.chart-fill-top { stop-color: var(--primary); stop-opacity: .28; }
.chart-fill-end { stop-color: var(--primary); stop-opacity: 0; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-prev { fill: none; stroke: var(--outline); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart-y { position: absolute; inset-inline-start: 0; transform: translateY(-120%); font-size: var(--typo-label-sm); color: var(--on-surface-variant); font-variant-numeric: tabular-nums; pointer-events: none; }
.chart-x { display: grid; grid-template-columns: 1fr auto 1fr; margin-top: 6px; font-size: var(--typo-label-sm); color: var(--on-surface-variant); white-space: nowrap; }
.chart-x span:first-child { justify-self: start; }
.chart-x span:last-child { justify-self: end; }
.chart-x span:only-child { grid-column: 2; }
.chart-cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--outline); pointer-events: none; }
.chart-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--surface-container-low); pointer-events: none; }
.chart-tip {
    position: absolute; top: 0; z-index: 2; display: grid; gap: 2px; min-width: 160px; padding: var(--space-2) var(--space-3);
    background: var(--inverse-surface, var(--on-surface)); color: var(--inverse-on-surface, var(--surface)); border-radius: var(--shape-sm);
    font-size: var(--typo-body-sm); box-shadow: var(--elev-2); pointer-events: none; white-space: nowrap; transform: translateX(12px);
}
.chart-tip.flip { transform: translateX(calc(-100% - 12px)); }
.chart-tip .muted { color: inherit; opacity: .75; }

/* Orders by status */
.ov-status { display: flex; flex-direction: column; }
.ov-ring { position: relative; width: 150px; margin: var(--space-2) auto var(--space-3); }
.ring { display: block; width: 100%; height: auto; }
.ov-ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.2; }
.ov-ring-label strong { font-family: var(--font-headline); font-size: var(--typo-headline-sm); }
.ov-ring-label .muted { font-size: var(--typo-label-md); }
.ov-legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ov-legend-list li { display: flex; align-items: center; gap: var(--space-1); font-size: var(--typo-body-md); }
.ov-legend-list li > span:first-of-type { flex: 1; }
.ov-paymix { margin-top: auto; padding-top: var(--space-4); }
.ov-paymix-bar { height: 8px; border-radius: var(--shape-full); background: linear-gradient(to right, var(--chart-5) var(--p), var(--chart-1) 0); }
.ov-paymix-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px var(--space-3); margin-top: var(--space-2); font-size: var(--typo-body-sm); }

/* Lists: top products, latest orders, running low */
.ov-rows { list-style: none; margin: 0; padding: 0; }
.ov-rows > li + li { border-top: 1px solid var(--outline-variant); }
.ov-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; min-height: 52px; color: inherit; text-decoration: none; }
.ov-row-link { margin-inline: calc(-1 * var(--space-2)); padding-inline: var(--space-2); border-radius: var(--shape-sm); }
.ov-row-link:hover { background: var(--surface-container); }
.ov-thumb, .ov-avatar {
    flex: none; width: 40px; height: 40px; border-radius: var(--shape-sm); object-fit: cover;
    display: grid; place-items: center; background: var(--surface-container-high); color: var(--on-surface-variant);
}
.ov-avatar { border-radius: 50%; background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; }
.ov-row-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.ov-row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ov-row-end { display: grid; justify-items: end; gap: 2px; text-align: end; font-variant-numeric: tabular-nums; }
.ov-bar { height: 6px; border-radius: var(--shape-full); background: linear-gradient(to right, var(--chart-3) var(--p), var(--surface-container-high) 0); }

/* What shoppers did */
.ov-funnel-note { margin: var(--space-2) 0 0; font-size: var(--typo-body-sm); }

/* Your store */
.ov-store dl { margin: 0; display: grid; }
.ov-kv { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; min-height: 44px; }
.ov-kv + .ov-kv { border-top: 1px solid var(--outline-variant); }
.ov-kv dt { color: var(--on-surface-variant); }
.ov-kv dd { margin: 0; text-align: end; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-kv a { display: inline-flex; align-items: center; gap: 4px; }

@media (max-width: 991px) {
    .ov-grid, .ov-grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 599px) {
    .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ov-kpi { padding: var(--space-3) var(--space-3) 40px; }
    .ov-kpi-value { font-size: var(--typo-title-lg); line-height: var(--typo-title-lg-lh); }
    .ov-chart { min-height: 200px; }
    .ov-toolbar .seg { width: 100%; }
    .ov-toolbar .seg button { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
    #overview-body, .ov-task { transition: none; }
}
