/* ============================================================================
   Dashboard design system — shared by every dashboard in the app
   (Nutrition, Account, Admin, Kitchen, Grocery, Content, Meal Plan).

   THE ONE RULE THAT SHAPES EVERYTHING HERE
   ----------------------------------------
   Separation is done with **tinted surfaces, spacing, radius and soft shadow**.
   There is no `border-left`, `border-top` or `border-bottom` anywhere in this
   file, and none should be added. The older dashboards leaned on accent stripes
   to say "this block is important"; the replacement is a surface tint plus scale,
   which reads as deliberate in both themes instead of like a highlighter.
   This continues the convention `plan-my-week.css` set — see its header.

   No gradients either (house style is glass, per CLAUDE.md). The only exception
   is a functional one: the SVG progress rings, whose colour *is* the data.

   THREE TIERS, AND WHY
   --------------------
   Every dashboard was a flat wall of identically-weighted `.card`s, which is the
   real reason they were hard to read. Everything here resolves to one of:

     .dash-hero    the single thing the page is about   (tinted, largest)
     .dash-stat    supporting figures, scannable in a row (neutral tint, medium)
     .dash-panel   detail and lists                     (plain surface, small)

   If a new block does not obviously belong to one of those three, that is a
   signal the page is showing something it does not need to.

   Colours resolve through Bootstrap theme variables and the macro tokens in
   site.css, so light/dark follow automatically and there is no second palette.
   ========================================================================== */

/* ── Scale tokens ─────────────────────────────────────────────────────────── */

.dash {
    /* Surface steps. The whole hierarchy is built out of these three, so a
       change here restyles every dashboard at once. */
    --dash-surface: var(--bs-body-bg);
    --dash-surface-sunken: var(--bs-tertiary-bg);
    --dash-surface-raised: var(--bs-secondary-bg);

    --dash-radius-lg: 1.25rem;
    --dash-radius: 0.9rem;
    --dash-radius-sm: 0.6rem;
    --dash-radius-pill: 999px;

    --dash-gap: 1rem;

    /* A full ring, never a single edge. */
    --dash-ring: 0 0 0 1px rgba(var(--bs-body-color-rgb), 0.06);
    --dash-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
    --dash-shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.05), 0 12px 28px rgba(0, 0, 0, 0.10);
}

[data-bs-theme="dark"] .dash {
    --dash-ring: 0 0 0 1px rgba(255, 255, 255, 0.07);
    --dash-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.28);
    --dash-shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.36), 0 14px 32px rgba(0, 0, 0, 0.42);
}

/* ── Page rhythm ──────────────────────────────────────────────────────────── */

.dash-section {
    margin-bottom: 1.75rem;
}

/* Section labels are metadata, so they stay quiet — the figures below them are
   what should carry the weight. */
.dash-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    margin-bottom: 0.75rem;
}

.dash-section-title .mdi {
    font-size: 0.95rem;
}

/* An action sitting on the right of a section label. */
.dash-section-title .dash-section-action {
    margin-left: auto;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 600;
    font-size: 0.8rem;
}

/* ── Tier 1: hero ─────────────────────────────────────────────────────────── */

.dash-hero {
    position: relative;
    border-radius: var(--dash-radius-lg);
    padding: 1.5rem;
    background-color: rgba(var(--bs-primary-rgb), 0.06);
    box-shadow: var(--dash-ring);
}

/* Accent variants — the tint changes, the structure does not. */
.dash-hero--success { background-color: rgba(var(--bs-success-rgb), 0.07); }
.dash-hero--info    { background-color: rgba(var(--bs-info-rgb), 0.07); }
.dash-hero--warning { background-color: rgba(var(--bs-warning-rgb), 0.09); }
.dash-hero--neutral { background-color: var(--dash-surface-sunken); }

.dash-hero-head {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    margin-bottom: 1.1rem;
}

.dash-hero-title {
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    margin-bottom: 0.1rem;
}

.dash-hero-sub {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0;
}

/* The one number the page exists to show. Tabular figures so it does not
   jitter as it counts up or refreshes. */
.dash-figure {
    font-size: clamp(2.1rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.dash-figure-unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
    letter-spacing: normal;
    margin-left: 0.3rem;
}

.dash-figure-caption {
    font-size: 0.82rem;
    color: var(--bs-secondary-color);
    margin-top: 0.35rem;
}

/* ── Icon mark ────────────────────────────────────────────────────────────── */

.dash-mark {
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 2.75rem;
    border-radius: var(--dash-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(var(--bs-primary-rgb), 0.12);
    color: var(--bs-primary);
}

.dash-mark .mdi {
    font-size: 1.45rem;
    line-height: 1;
}

.dash-mark--sm {
    width: 2.1rem;
    height: 2.1rem;
    flex-basis: 2.1rem;
    border-radius: var(--dash-radius-sm);
}

.dash-mark--sm .mdi { font-size: 1.1rem; }

.dash-mark--success { background-color: rgba(var(--bs-success-rgb), 0.14); color: var(--bs-success); }
.dash-mark--info    { background-color: rgba(var(--bs-info-rgb), 0.14);    color: var(--bs-info); }
.dash-mark--warning { background-color: rgba(var(--bs-warning-rgb), 0.16); color: var(--bs-warning-text-emphasis, var(--bs-warning)); }
.dash-mark--danger  { background-color: rgba(var(--bs-danger-rgb), 0.14);  color: var(--bs-danger); }
.dash-mark--neutral { background-color: var(--dash-surface-raised);        color: var(--bs-secondary-color); }

/* ── Tier 2: stat tiles ───────────────────────────────────────────────────── */

.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: var(--dash-gap);
}

/* Tighter variant for count-only area homes (Kitchen/Grocery/Content), which
   have many small figures rather than a few important ones. */
.dash-stats--dense {
    grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
    gap: 0.75rem;
}

.dash-stat {
    background-color: var(--dash-surface-sunken);
    border-radius: var(--dash-radius);
    padding: 0.95rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.dash-stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.dash-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--bs-body-color);
}

.dash-stat-meta {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

/* A stat that navigates. Given a real affordance rather than a mystery click. */
a.dash-stat,
.dash-stat--action {
    text-decoration: none;
    color: inherit;
    transition: background-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

a.dash-stat:hover,
.dash-stat--action:hover {
    background-color: var(--dash-surface-raised);
    transform: translateY(-2px);
    box-shadow: var(--dash-shadow);
    color: inherit;
}

a.dash-stat:focus-visible,
.dash-stat--action:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* ── Delta chips ──────────────────────────────────────────────────────────── */

.dash-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.12rem 0.45rem;
    border-radius: var(--dash-radius-pill);
    font-variant-numeric: tabular-nums;
}

.dash-delta--up   { background-color: rgba(var(--bs-success-rgb), 0.14); color: var(--bs-success-text-emphasis, var(--bs-success)); }
.dash-delta--down { background-color: rgba(var(--bs-danger-rgb), 0.14);  color: var(--bs-danger-text-emphasis, var(--bs-danger)); }
.dash-delta--flat { background-color: var(--dash-surface-raised);        color: var(--bs-secondary-color); }

/* ── Quiet pills (metadata, streaks, filters) ─────────────────────────────── */

.dash-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--dash-radius-pill);
    background-color: var(--dash-surface-raised);
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.dash-pill--accent  { background-color: rgba(var(--bs-primary-rgb), 0.12); color: var(--bs-primary); }
.dash-pill--success { background-color: rgba(var(--bs-success-rgb), 0.14); color: var(--bs-success-text-emphasis, var(--bs-success)); }
.dash-pill--warning { background-color: rgba(var(--bs-warning-rgb), 0.16); color: var(--bs-warning-text-emphasis, var(--bs-warning)); }

.dash-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* ── Tier 3: panels ───────────────────────────────────────────────────────── */

.dash-panel {
    background-color: var(--dash-surface);
    border-radius: var(--dash-radius-lg);
    box-shadow: var(--dash-ring), var(--dash-shadow);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Opt in to filling the column. NOT the default: a Bootstrap column is a stretched
   flex item, so a panel that is 100% tall by default balloons to the height of the
   tallest column and leaves a large empty gap under its content. Add this only when
   two panels genuinely need to line up. */
.dash-panel--fill { height: 100%; }

.dash-panel--flush { padding: 0; }
.dash-panel--sunken { background-color: var(--dash-surface-sunken); box-shadow: none; }

.dash-panel-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.dash-panel--flush .dash-panel-head { padding: 1.25rem 1.25rem 0; margin-bottom: 0.85rem; }

.dash-panel-title {
    font-size: 0.95rem;
    font-weight: 650;
    margin-bottom: 0;
    letter-spacing: -0.005em;
}

.dash-panel-sub {
    font-size: 0.78rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0;
}

.dash-panel-action { margin-left: auto; }

.dash-panel-body { flex: 1 1 auto; min-height: 0; }

/* Scrollable list bodies. max-height lives here rather than as an inline style
   on each view, which is how the old dashboards did it. */
.dash-scroll {
    overflow-y: auto;
    max-height: 22rem;
    /* Wide content must scroll inside the panel, never the page. */
    overflow-x: auto;
}

.dash-scroll--tall { max-height: 30rem; }

/* ── Rows inside panels ───────────────────────────────────────────────────── */

.dash-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--dash-radius-sm);
    transition: background-color 0.14s ease;
    min-width: 0;
}

.dash-row + .dash-row { margin-top: 0.15rem; }

.dash-row:hover { background-color: var(--dash-surface-sunken); }

a.dash-row { text-decoration: none; color: inherit; }
a.dash-row:hover { color: inherit; }
a.dash-row:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 1px; }

.dash-row-main { flex: 1 1 auto; min-width: 0; }

.dash-row-title {
    font-size: 0.88rem;
    font-weight: 550;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-row-meta {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-row-value {
    font-size: 0.85rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */

.dash-bar {
    position: relative;
    height: 0.5rem;
    border-radius: var(--dash-radius-pill);
    background-color: rgba(var(--bs-body-color-rgb), 0.09);
    overflow: hidden;
}

.dash-bar--tall { height: 0.7rem; }

.dash-bar-fill {
    height: 100%;
    border-radius: inherit;
    background-color: var(--bs-primary);
    width: 0;
    transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Over-target is information, not an error — it gets its own colour rather than
   silently clamping at 100%. */
.dash-bar-fill--over { background-color: var(--bs-danger); }
.dash-bar-fill--good { background-color: var(--bs-success); }

/* Macro-coloured fills, reading the single source of truth in site.css. */
.dash-bar-fill--calories { background-color: var(--macro-calories); }
.dash-bar-fill--protein  { background-color: var(--macro-protein); }
.dash-bar-fill--carbs    { background-color: var(--macro-carbs); }
.dash-bar-fill--fat      { background-color: var(--macro-fat); }

/* ── Progress ring (SVG) ──────────────────────────────────────────────────── */

.dash-ring-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.dash-ring-svg {
    transform: rotate(-90deg);
    display: block;
}

.dash-ring-track {
    fill: none;
    stroke: rgba(var(--bs-body-color-rgb), 0.10);
}

.dash-ring-value {
    fill: none;
    stroke: var(--bs-primary);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.dash-ring-value--calories { stroke: var(--macro-calories); }
.dash-ring-value--protein  { stroke: var(--macro-protein); }
.dash-ring-value--carbs    { stroke: var(--macro-carbs); }
.dash-ring-value--fat      { stroke: var(--macro-fat); }
.dash-ring-value--success  { stroke: var(--bs-success); }
.dash-ring-value--over     { stroke: var(--bs-danger); }

.dash-ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.1;
}

.dash-ring-pct {
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dash-ring-cap {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bs-secondary-color);
}

/* ── Macro tiles ──────────────────────────────────────────────────────────── */

.dash-macros {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.75rem;
}

.dash-macro {
    background-color: var(--dash-surface-sunken);
    border-radius: var(--dash-radius);
    padding: 0.85rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.dash-macro-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.4rem;
}

.dash-macro-name {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.dash-macro-value {
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.dash-macro-target {
    font-size: 0.72rem;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
}

/* Dot markers keep macro identity without tinting the whole tile. */
.dash-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

.dash-dot--calories { background-color: var(--macro-calories); }
.dash-dot--protein  { background-color: var(--macro-protein); }
.dash-dot--carbs    { background-color: var(--macro-carbs); }
.dash-dot--fat      { background-color: var(--macro-fat); }

/* ── Sparkline ────────────────────────────────────────────────────────────── */

.dash-spark {
    display: block;
    width: 100%;
    height: 2.25rem;
    overflow: visible;
}

.dash-spark-line {
    fill: none;
    stroke: var(--bs-primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.dash-spark-area { fill: rgba(var(--bs-primary-rgb), 0.10); stroke: none; }

/* ── Chart panels ─────────────────────────────────────────────────────────── */

/* Chart.js needs a bounded parent or it grows without limit on resize. */
.dash-chart {
    position: relative;
    width: 100%;
    height: 16rem;
}

.dash-chart--sm { height: 11rem; }
.dash-chart--lg { height: 21rem; }

/* ── Empty states ─────────────────────────────────────────────────────────── */

.dash-empty {
    text-align: center;
    padding: 2.25rem 1rem;
    color: var(--bs-secondary-color);
}

.dash-empty .mdi {
    font-size: 2.4rem;
    opacity: 0.4;
    display: block;
    margin-bottom: 0.5rem;
}

.dash-empty-title {
    font-weight: 600;
    color: var(--bs-body-color);
    margin-bottom: 0.2rem;
}

.dash-empty-text { font-size: 0.85rem; margin-bottom: 0.9rem; }

/* ── Skeletons (for the AJAX-loaded panels) ───────────────────────────────── */

.dash-skeleton {
    background-color: var(--dash-surface-sunken);
    border-radius: var(--dash-radius-sm);
    height: 1rem;
    animation: dash-pulse 1.4s ease-in-out infinite;
}

.dash-skeleton + .dash-skeleton { margin-top: 0.5rem; }

@keyframes dash-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* ── Motion ───────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .dash-bar-fill,
    .dash-ring-value,
    a.dash-stat,
    .dash-stat--action,
    .dash-row,
    .dash-skeleton {
        transition: none;
        animation: none;
    }

    a.dash-stat:hover,
    .dash-stat--action:hover { transform: none; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
    .dash-hero { padding: 1.15rem; }
    .dash-panel { padding: 1rem; }
    .dash-figure { font-size: 2rem; }
    .dash-stats { grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.7rem; }
    .dash-chart { height: 13rem; }
}
