/* ══════════════════════════════════════════════════════════════════
   Cards — flat solid surface per brand_identity_v2.md §5.2
   Cycle 17 B: glass-morphism DEMOTED. The prototype is flat, solid and
   confident — solid white cards, a crisp 1px border, a barely-there
   shadow. No backdrop-filter on card surfaces. The `--surface-glass-*`
   and `--glass-*` tokens are NOT deleted (Lane A keeps them defined);
   they are simply no longer applied as a headline card style.
   ══════════════════════════════════════════════════════════════════ */

/* Base card — flat white surface, 1px line border, 12px radius, faint
   shadow. Bootstrap's default `.card` background/border get replaced. */
.card {
  background: var(--wasla-surface, #ffffff);
  border: 1px solid var(--wasla-line, #E4E7EC);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(20, 40, 70, 0.06);
  transition: box-shadow var(--motion-card, 200ms ease),
              transform var(--motion-card, 200ms ease),
              border-color var(--motion-hover, 150ms ease-out);
}

/* Clickable cards (KPI tiles, link cards) get a slight lift + a
   blue-tinted hover border. Reduced-motion zeroes the motion tokens
   so the lift is instant. */
.card-clickable,
.kpi-row .card,
.card-stat {
  cursor: pointer;
}

.card-clickable:hover,
.kpi-row .card:hover,
.card-stat:hover {
  box-shadow: 0 4px 12px rgba(20, 40, 70, 0.10);
  transform: translateY(-1px);
  border-color: var(--wasla-blue, #0557E7);
}

/* Buttons — press effect only. We do NOT apply glass to buttons. */
.btn:active {
  transform: scale(0.98);
  transition: transform var(--motion-press, 80ms ease-in);
}

/* Cards inside <table>, <td>, or <th> contexts stay solid white —
   no special treatment needed now that the base card is already flat,
   but the explicit rule is kept for clarity. */
table .card,
td .card,
th .card {
  background: #ffffff;
}

[data-bs-theme="dark"] table .card,
[data-bs-theme="dark"] td .card,
[data-bs-theme="dark"] th .card {
  background: var(--wasla-surface);
}

/* Bootstrap's default .text-success (#198754) and .text-danger (#dc3545)
   render at 4.49:1 on the off-white card bg — exactly under WCAG AA's
   4.5:1 by 0.01. We darken them inside cards only so AA passes without
   affecting outside-card usage. */
.card .text-success { color: #146c43 !important; }
.card .text-danger  { color: #b02a37 !important; }
[data-bs-theme="dark"] .card .text-success { color: #75b798 !important; }
[data-bs-theme="dark"] .card .text-danger  { color: #ea868f !important; }

/* ══════════════════════════════════════════════════════════════════
   Design-uplift P3 — quiet-glass KPI cards, delta chips, the AI moment,
   setup checklist, skeletons. Scoped to the dashboard shell
   (body.qg-chrome, applied by layouts/dashboard_base.html).
   Selector note: `:root` prefixes match the (0,3,0) specificity of
   app.css's OS-dark fallback block (`:root:not([data-bs-theme="light"])
   .card { background: ... }`, app.css:848) — this file loads later, so
   equal specificity resolves to quiet-glass in every theme/OS combo.
   ══════════════════════════════════════════════════════════════════ */

/* KPI cards: glass-lite per the audit mockup (light rgba(255,255,255,.55)
   blur(14px) sat(1.1); dark rgba(18,30,52,.55) sat(1.08)). Content cards
   only — tables/forms stay solid. Radius 14 per the v3 scale. */
:root .qg-chrome .card-metric {
  background: var(--glass-bg-lite);
  -webkit-backdrop-filter: blur(14px) saturate(var(--glass-saturate));
  backdrop-filter: blur(14px) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card, 14px);
  box-shadow: var(--glass-edge), 0 10px 24px rgba(23, 42, 72, 0.05);
}

/* (Dark mode needs no extra rule here: --glass-bg-lite/--glass-border/
   --glass-saturate all flip under [data-bs-theme="dark"] in tokens.css.) */

/* KPI value: display family at the mockup's 25px, unit rendered smaller
   and faint (the |money filter's trailing symbol span). */
.qg-chrome .card-metric .metric-value {
  font-family: var(--font-display, inherit);
  font-size: 1.5625rem; /* 25px */
}

.qg-chrome .card-metric .metric-value .cycle4-rtl-currency > span:last-child {
  font-size: 0.68em;
  font-weight: 600;
  color: var(--text-faint);
}

/* Delta chip under a KPI value: success/warning/neutral per the
   component spec ("never a bare number without context"). */
.qg-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
  font-size: 0.71875rem; /* 11.5px */
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.qg-delta--up   { background: var(--chip-success-bg); color: var(--chip-success-text); }
.qg-delta--down { background: var(--chip-warning-bg); color: var(--chip-warning-text); }
.qg-delta--flat { background: var(--chip-neutral-bg); color: var(--chip-neutral-text); }

/* ── The AI moment (gold signature) ──
   Glass bg + 35%-alpha GOLD border + caps eyebrow + navy headline + ONE
   blue text-link. The only place gold borders appear (component spec). */
:root .qg-chrome .qg-ai-insight {
  background: var(--glass-bg-lite);
  -webkit-backdrop-filter: blur(14px) saturate(var(--glass-saturate));
  backdrop-filter: blur(14px) saturate(var(--glass-saturate));
  border: 1px solid rgba(212, 175, 54, 0.38);
  border-radius: var(--radius-card, 14px);
  box-shadow: var(--glass-edge), 0 10px 24px rgba(23, 42, 72, 0.05);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

[data-bs-theme="dark"] .qg-chrome .qg-ai-insight {
  border-color: rgba(224, 194, 92, 0.35);
}

.qg-ai-insight__eyebrow {
  font-size: 0.6875rem; /* 11px */
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9A7B1E; /* gold-dark: AA on the light glass (plain gold fails) */
}

[data-bs-theme="dark"] .qg-ai-insight__eyebrow {
  color: var(--wasla-gold, #E0C25C);
}

.qg-ai-insight__headline {
  font-weight: 600;
  color: var(--text-heading);
}

.qg-ai-insight__action {
  align-self: flex-start;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--wasla-blue);
  text-decoration: none;
}

.qg-ai-insight__action:hover,
.qg-ai-insight__action:focus-visible {
  text-decoration: underline;
  color: var(--wasla-blue-hover);
}

/* ── First-run setup checklist (blind-spot #4) ──
   Dashed-border card per the "Empty states" recipe. */
.qg-checklist {
  border: 1px dashed var(--border-strong, #DDE2EA);
  border-radius: var(--radius-card, 14px);
  background: var(--surface-raised, #FAFBFD);
  padding: 18px;
}

.qg-checklist__title {
  font-family: var(--font-display, inherit);
  font-weight: 700;
  color: var(--text-heading);
}

.qg-checklist__progress {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.qg-checklist__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qg-checklist__item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--text-body);
}

.qg-checklist__item a {
  color: var(--wasla-blue);
  font-weight: 600;
  text-decoration: none;
}

.qg-checklist__item a:hover,
.qg-checklist__item a:focus-visible {
  text-decoration: underline;
}

.qg-checklist__item.is-done {
  color: var(--text-faint);
  text-decoration: line-through;
}

.qg-checklist__mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong, #DDE2EA);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  flex-shrink: 0;
}

.qg-checklist__item.is-done .qg-checklist__mark {
  background: var(--wasla-success, #1F9D6B);
  border-color: var(--wasla-success, #1F9D6B);
  color: #fff;
}

/* ── Skeletons (blind-spot #3): shimmer in place, never spinners ──
   Apply .qg-skeleton to a layout-exact placeholder block. */
.qg-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-control, 9px);
  background: var(--chip-neutral-bg, rgba(29, 58, 94, 0.07));
  color: transparent;
  pointer-events: none;
  user-select: none;
}

.qg-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.55),
    transparent
  );
  animation: qg-shimmer 1.4s ease-in-out infinite;
}

[data-bs-theme="dark"] .qg-skeleton::after {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.08),
    transparent
  );
}

@keyframes qg-shimmer {
  100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .qg-skeleton::after {
    animation: none;
  }
}

/* Fallbacks: no backdrop-filter / reduced transparency → solid cards. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root .qg-chrome .card-metric,
  :root .qg-chrome .qg-ai-insight {
    background: var(--surface-solid, #ffffff);
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root .qg-chrome .card-metric,
  :root .qg-chrome .qg-ai-insight {
    background: var(--surface-solid, #ffffff);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
