/* ═══════════════════════════════════════════════════════════
   Cards & panels — extracted from TNonline
   (NewBooking card-section / Settings section / KpiCard)
   ═══════════════════════════════════════════════════════════ */

/* ── Plain card ── */
.tn-card {
    background: var(--tn-bg-card);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-lg);
    padding: var(--tn-space-lg);
}

.tn-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--tn-text-primary);
    margin: 0 0 var(--tn-space-md);
    padding-bottom: var(--tn-space-xs);
    border-bottom: 2px solid var(--tn-accent-light);
}

/* Selectable card (e.g. choice tiles) */
.tn-card--selectable {
    cursor: pointer;
    transition: all var(--tn-transition);
}

.tn-card--selectable:hover {
    border-color: var(--tn-accent);
    box-shadow: var(--tn-shadow-md);
}

.tn-card--selectable.is-selected {
    border-color: var(--tn-accent);
    box-shadow: 0 0 0 3px rgba(var(--tn-accent-rgb), 0.12);
    background: var(--tn-accent-light);
}

/* ── Section panel (header + body), used for grouped settings ── */
.tn-section {
    background: var(--tn-bg-card);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-lg);
    overflow: hidden;
    margin-bottom: var(--tn-space-md);
}

.tn-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--tn-border);
    background: var(--tn-bg-page);
}

.tn-section-header h3 {
    margin: 0;
    font-size: var(--tn-font-size-base);
    font-weight: 600;
    color: var(--tn-text-primary);
}

.tn-section-header .bi {
    font-size: 1.05rem;
    color: var(--tn-text-secondary);
}

.tn-section-body {
    padding: 22px;
}

.tn-section-description {
    margin: 0 0 18px;
    font-size: var(--tn-font-size-sm);
    color: var(--tn-text-secondary);
    line-height: 1.5;
}

/* ── KPI card ── */
.tn-kpi {
    display: flex;
    align-items: flex-start;
    gap: var(--tn-space-md);
    padding: 20px;
    background: var(--tn-bg-card);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-lg);
}

.tn-kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: var(--tn-radius);
    background: var(--tn-accent-light);
    color: var(--tn-accent);
    font-size: 1.1rem;
}

/* Status-toned icon tile — same tint pairs as badges.css's five tones,
   for a KPI whose icon should read as good/bad/pending rather than
   always the neutral accent (e.g. per-order-status KPIs). */
.tn-kpi-icon--amber { background: var(--tn-warning-light); color: var(--tn-warning-text); }
.tn-kpi-icon--green { background: var(--tn-success-light); color: var(--tn-success-text); }
.tn-kpi-icon--red { background: var(--tn-danger-light); color: var(--tn-danger-text); }
.tn-kpi-icon--gray { background: var(--tn-bg-page); color: var(--tn-text-secondary); }

.tn-kpi-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tn-kpi-title {
    font-size: var(--tn-font-size-xs);
    color: var(--tn-text-secondary);
    font-weight: 500;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tn-kpi-value-row {
    display: flex;
    align-items: baseline;
    gap: var(--tn-space-xs);
}

.tn-kpi-value {
    font-size: clamp(var(--tn-font-size-xl), 1rem + 0.9vw, var(--tn-font-size-2xl));
    font-weight: 700;
    color: var(--tn-text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.tn-kpi-unit {
    font-size: var(--tn-font-size-sm);
    color: var(--tn-text-muted);
    font-weight: 500;
}

.tn-kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: var(--tn-font-size-xs);
    font-weight: 600;
    line-height: 1;
    margin-top: 2px;
}

/* -text variants, not the vivid base tokens — this is body text, not a
   decorative fill. --positive was on --tn-success at 4.27:1/3.91:1
   (card/page), under AA; --negative already passed on --tn-danger (5.47)
   but is moved to match, so the pair isn't split across two conventions. */
.tn-kpi-trend--positive {
    color: var(--tn-success-text);
}

.tn-kpi-trend--negative {
    color: var(--tn-danger-text);
}

/* Selectable KPI — for KPI cards used as filter toggles rather than pure
   display (click "12 pending" to filter the list to pending). Same
   treatment as .tn-card--selectable above, applied to .tn-kpi instead
   of requiring the consumer to wrap a .tn-card around it. */
.tn-kpi--selectable {
    cursor: pointer;
    transition: all var(--tn-transition);
}

.tn-kpi--selectable:hover {
    border-color: var(--tn-accent);
    box-shadow: var(--tn-shadow-md);
}

.tn-kpi--selectable.is-selected {
    border-color: var(--tn-accent);
    box-shadow: 0 0 0 3px rgba(var(--tn-accent-rgb), 0.12);
    background: var(--tn-accent-light);
}

/* ── KPI grid — responsive row of KPI cards ──
   The canonical way to lay out .tn-kpi cards so every product arranges
   them identically: auto-fit columns, wrapping to as many per row as fit.
   Apps can still use their own layout; this is the shared default. */
.tn-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--tn-space-md);
    /* Matches .tn-toolbar's existing margin-bottom (toolbar.css) so
       stacking this against a sibling inside .tn-section-body doesn't
       collapse to a 0px gap. Stopgap — see issue #90 for why
       .tn-section-body should own this rhythm instead, and why that's
       deferred rather than done now. */
    margin-bottom: var(--tn-space-md);
}

/* Info pair (label over value), used inside cards */
.tn-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.tn-info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tn-info-label {
    font-size: var(--tn-font-size-xs);
    font-weight: 600;
    color: var(--tn-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tn-info-value {
    font-size: var(--tn-font-size-sm);
    font-weight: 500;
    color: var(--tn-text-primary);
    word-break: break-word;
}

@media (max-width: 768px) {
    .tn-info-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

/* ── Mobile density — tighten the roomy desktop padding on phones so
   content feels dense + premium rather than floating in whitespace. ── */
@media (max-width: 640px) {
    .tn-card {
        padding: var(--tn-space-md); /* 24px → 16px */
    }

    .tn-section-header {
        padding: 12px var(--tn-space-md); /* 14px 20px → 12px 16px */
    }

    .tn-section-body {
        padding: var(--tn-space-md); /* 22px → 16px */
    }

    .tn-kpi {
        padding: var(--tn-space-md); /* 20px → 16px */
    }

    /* ── Section wrapping table-cards — drop the section's own frame ──
       Below 640px, .tn-table--cards already draws its own per-row card
       (bg/border/radius — see tables.css) and .tn-table--cards-wrapper
       already drops its own frame around that (tables.css's own
       max-width:640px block). A .tn-section still wrapping one at this
       width was left drawing a THIRD, visually-identical frame around
       already-framed rows: same white fill, same border color, same
       radius, nested. Ludvig, looking at the exact mobile list shown at
       the Wednesday demo: "it feels like 2 level of cards... too much
       same." Desktop is unaffected: there the section correctly frames a
       plain table that has no frame of its own. The row-cards keep their
       own frame either way — the tappable-object cue #546 built stays
       intact — only the outer section wrapper goes transparent, since the
       page gutter already positions the cards without it. */
    .tn-section:has(.tn-table--cards-wrapper) {
        background: none;
        border: none;
        border-radius: 0;
        overflow: visible;
    }

    .tn-section-body:has(> .tn-table--cards-wrapper) {
        padding: 0;
    }
}
