/* ============================================================================
   dashboard-kit.css — the shared dashboard design system for every portal
   ----------------------------------------------------------------------------
   ONE look across the agent, manager (team) and user consoles. Each portal has
   its own sheet (agentbackend / teambackend / userbackend) that supplies the
   design TOKENS; this kit consumes those tokens and adds nothing portal-specific,
   so it inherits each portal's palette + light/dark theme for free.

   Everything is namespaced `.crk-*` (Common Realtor Kit) so it can never collide
   with the generic public/admin class names that have bled into portal markup
   before (see the "public CSS class collisions" note). Add dashboard primitives
   here; do not fork them into three sheets.

   The pieces:
     .crk-kpis / .crk-kpi ....... the at-a-glance metric row (delta + sparkline)
     .crk-grid .................. main + rail two-column dashboard layout
     .crk-panel / .crk-sec-h .... a titled content card + section header
     .crk-queue / .crk-q ........ the "needs you today" attention list
     .crk-ring .................. a momentum / goal progress ring
   Every value leans on tokens with a hard fallback so a missing token in one
   portal degrades gracefully instead of rendering an undefined color.
   ========================================================================== */

/* ── KPI ROW ──────────────────────────────────────────────────────────────
   Headline numbers read as instruments, not stats: an accent spine, a big
   tabular number, a status delta chip (arrow + %), and an optional sparkline.
   Give each tile `style="--kc:<accent>"` to colour its spine + sparkline. */
.crk-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.9rem;
    margin: 0 0 1.5rem;
}
.crk-kpi {
    --kc: var(--brand, #db252b);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e6e8ec);
    border-radius: 16px;
    padding: 1.15rem 1.3rem 1.2rem 1.5rem;
    overflow: hidden;
    text-align: left;
    font: inherit;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.crk-kpi::before {                    /* the accent spine */
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--kc);
}
a.crk-kpi, button.crk-kpi { cursor: pointer; }
a.crk-kpi:hover, button.crk-kpi:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--kc) 45%, var(--border, #e6e8ec));
    box-shadow: 0 14px 30px rgba(16, 24, 40, 0.09);
}
.crk-kpi-l {                          /* label */
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-faint, #98a2b3);
}
.crk-kpi-n {                          /* the number */
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.5px;
    color: var(--text, #1a202c);
    font-variant-numeric: tabular-nums;
    margin-top: 0.25rem;
}
.crk-kpi-foot {                       /* delta chip + note sit on one line */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    min-height: 1.2rem;
}
.crk-kpi-note {
    font-size: 0.78rem;
    color: var(--text-muted, #667085);
    line-height: 1.3;
}
.crk-kpi-ic {                         /* faint watermark icon, top-right */
    position: absolute;
    top: 1rem; right: 1.05rem;
    color: var(--kc);
    opacity: 0.22;
    pointer-events: none;
}
.crk-kpi-ic svg { display: block; }

/* Delta chip — status colour, ALWAYS with an arrow glyph so it never relies on
   colour alone (colourblind-safe by construction). */
.crk-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0.1rem 0.45rem 0.1rem 0.35rem;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.crk-delta::before { font-size: 0.72rem; line-height: 1; }
.crk-delta.up   { color: var(--success, #2f855a); background: var(--success-tint, #e7f5ee); }
.crk-delta.up::before   { content: "\2191"; }   /* ↑ */
.crk-delta.down { color: var(--danger, #db252b);  background: var(--danger-tint, #fdecec); }
.crk-delta.down::before { content: "\2193"; }   /* ↓ */
.crk-delta.flat { color: var(--text-muted, #667085); background: var(--bg-muted, #f1f3f5); }
.crk-delta.flat::before { content: "\2192"; }   /* → */

/* Sparkline — single-series trend, one hue, thin stroke, rounded ends. Feed it
   an inline <svg> via crkSpark(); it scales to the tile. */
.crk-spark { width: 100%; height: 30px; margin-top: 0.55rem; display: block; }
.crk-spark path.line { fill: none; stroke: var(--kc); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.crk-spark path.area { fill: var(--kc); opacity: 0.10; stroke: none; }
.crk-spark circle.head { fill: var(--kc); }

/* ── TWO-COLUMN DASHBOARD LAYOUT ──────────────────────────────────────────
   Main content + a narrower rail (attention queue, momentum). Collapses to a
   single column below 960px so the rail drops under the main content. */
.crk-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.25rem;
    align-items: start;
}
.crk-grid > .crk-col { min-width: 0; display: flex; flex-direction: column; gap: 1.25rem; }
@media (max-width: 960px) {
    .crk-grid { grid-template-columns: 1fr; }
    .crk-grid > .crk-rail { order: -1; }   /* on mobile, "needs you" comes first */
}

/* ── PANEL + SECTION HEADER ────────────────────────────────────────────────*/
.crk-panel {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e6e8ec);
    border-radius: 16px;
    padding: 1.3rem 1.4rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.crk-panel.pad-lg { padding: 1.6rem 1.75rem; }
.crk-sec-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1rem;
}
.crk-sec-h h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text, #1a202c);
}
.crk-sec-h .crk-sec-sub { font-size: 0.82rem; color: var(--text-muted, #667085); font-weight: 500; margin-top: 0.15rem; }
.crk-sec-link {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand, #db252b);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}
.crk-sec-link:hover { text-decoration: underline; }

/* ── ATTENTION QUEUE — the "needs you today" list ─────────────────────────
   Prioritised, clickable rows. This is what turns the dashboard from a report
   into a to-do surface. Priority is shown by a coloured dot + label, not colour
   alone. */
.crk-queue { display: flex; flex-direction: column; gap: 0.4rem; }
.crk-q {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e6e8ec);
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    font: inherit;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.crk-q:hover {
    border-color: color-mix(in srgb, var(--brand, #db252b) 35%, var(--border, #e6e8ec));
    background: color-mix(in srgb, var(--brand, #db252b) 4%, var(--surface, #fff));
    transform: translateX(2px);
}
.crk-q-ic {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--pc-tint, var(--brand-tint, #fde7e7));
    color: var(--pc, var(--brand, #db252b));
}
.crk-q-ic svg { width: 17px; height: 17px; }
.crk-q-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.crk-q-t {
    display: block;
    max-width: 100%;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text, #1a202c);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crk-q-d {
    display: block;
    max-width: 100%;
    font-size: 0.78rem;
    color: var(--text-muted, #667085);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.1rem;
}
.crk-q-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 0.55rem; }
.crk-q-chip {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--pc-tint, var(--brand-tint, #fde7e7));
    color: var(--pc, var(--brand, #db252b));
    white-space: nowrap;
}
.crk-q-chev { color: var(--text-faint, #98a2b3); flex: 0 0 auto; }
/* Priority accents — set on the row via a class; drives the icon + chip colour */
.crk-q.pri-hot    { --pc: var(--danger, #db252b);  --pc-tint: var(--danger-tint, #fdecec); }
.crk-q.pri-warm   { --pc: var(--warning, #d97706); --pc-tint: #fff3e2; }
.crk-q.pri-cool   { --pc: var(--brand, #db252b);   --pc-tint: var(--brand-tint, #fde7e7); }
.crk-q.pri-done   { --pc: var(--success, #2f855a); --pc-tint: var(--success-tint, #e7f5ee); }

/* Empty state for the queue — "you're all caught up" */
.crk-q-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    padding: 1.75rem 1rem;
    color: var(--text-muted, #667085);
}
.crk-q-empty svg { color: var(--success, #2f855a); opacity: 0.8; }
.crk-q-empty .t { font-weight: 700; color: var(--text, #1a202c); font-size: 0.95rem; }
.crk-q-empty .d { font-size: 0.82rem; }

/* ── MOMENTUM / GOAL RING ─────────────────────────────────────────────────
   A single progress ring anchors the rail visually. Set the fill with
   `style="--pct:72; --kc:<accent>"` (0–100). */
.crk-ring-wrap { display: flex; align-items: center; gap: 1.1rem; }
.crk-ring {
    --pct: 0;
    --kc: var(--brand, #db252b);
    flex: 0 0 auto;
    width: 92px; height: 92px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background:
        conic-gradient(var(--kc) calc(var(--pct) * 1%), var(--ring-track, var(--bg-muted, #eef0f3)) 0);
}
.crk-ring::before {
    content: "";
    position: absolute;
    width: 68px; height: 68px;
    border-radius: 50%;
    background: var(--surface, #fff);
}
.crk-ring { position: relative; }
.crk-ring-val {
    position: relative;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text, #1a202c);
    font-variant-numeric: tabular-nums;
}
.crk-ring-txt .t { font-size: 0.9rem; font-weight: 700; color: var(--text, #1a202c); }
.crk-ring-txt .d { font-size: 0.8rem; color: var(--text-muted, #667085); margin-top: 0.2rem; line-height: 1.4; }

/* Reduced motion — kill the lift/slide transitions */
@media (prefers-reduced-motion: reduce) {
    .crk-kpi, .crk-q { transition: none; }
    a.crk-kpi:hover, button.crk-kpi:hover, .crk-q:hover { transform: none; }
}
