/*
 * Vayu SMS design system.
 * Tokens are taken verbatim from README.md "Design Tokens" and the inline <style> block in the
 * .dc.html files. Bootstrap 5.3.8 supplies the grid and a few utilities; everything with a visual
 * identity (cards, badges, buttons, sidebar, tables) is defined here, because the design's 2px ink
 * borders and pill badges are not Bootstrap's look.
 */

/*
 * PALETTE: Aviatrack, not Vayu.
 *
 * The token NAMES are unchanged so none of the ~1,400 lines of rules below need editing —
 * only the values behind them. Everything is remapped onto app-theme.css so SMS reads as
 * part of Aviatrack: Aptos instead of Archivo, hairline borders instead of 2px ink, 8/10px
 * radii instead of 10/16/20, and the muted navy/blue palette instead of the high-contrast
 * ink/sky one.
 *
 * The four-step risk scale is kept as four distinguishable steps, because low/medium/high/
 * intolerable is a regulatory distinction, not decoration — it is just moved into
 * Aviatrack's quieter register.
 */

:root {
  /* Palette — mapped to app-theme.css */
  --ink: #111c29;              /* app-theme --ink */
  --sky: #2f7de1;              /* app-theme --accent */
  --sky-dark: #246bc1;         /* app-theme --accent-dark */
  --sky-darker: #1d569b;
  --sky-tint: #eaf2fc;         /* app-theme --accent-wash */
  --sky-tint-2: #d3e4f8;
  --green: #16794f;            /* app-theme --ok */
  --yellow: #8a6d0b;           /* medium — darkened for contrast on tint */
  --orange: #9a5b0a;           /* app-theme --warn */
  --red: #b42318;              /* app-theme --danger */

  --bg: #f6f8fc;               /* app-theme --bg */
  --card: #ffffff;             /* app-theme --surface */
  --muted: #667281;            /* app-theme --muted */
  --muted-2: #8b949e;          /* app-theme --faint */
  --line: rgba(10, 16, 49, 0.10);        /* app-theme --line */
  --line-strong: rgba(10, 16, 49, 0.16); /* app-theme --line-strong */
  --sidebar-text: #c8d2e4;
  --sidebar-dim: #7f8ba3;

  /* Risk tints, used by badges and status cells */
  --tint-low: #e7f5ee;         /* app-theme --ok-wash */
  --tint-medium: #fbf6e0;
  --tint-high: #fdf3e0;        /* app-theme --warn-wash */
  --tint-critical: #fdeceb;    /* app-theme --danger-wash */

  --radius-sm: 6px;
  --radius-md: 8px;            /* app-theme --radius */
  --radius-lg: 10px;           /* app-theme --radius-lg */
  --radius-xl: 12px;

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 76px;

  /* Bootstrap overrides so its own components inherit the palette */
  --bs-body-font-family: "Aptos", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-primary: var(--sky);
  --bs-link-color: var(--sky-dark);
  --bs-link-hover-color: var(--sky);
  --bs-border-radius: var(--radius-md);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sky-dark); text-decoration: none; }
a:hover { color: var(--sky); }

/* ==========================================================================
   Layout — sidebar + topbar shell
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.15s ease;
}
.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar {
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a3556; border-radius: 3px; }

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid #1c2647;
}
.wordmark {
  width: 36px; height: 36px;
  flex: 0 0 36px;
  border-radius: var(--radius-md);
  background: var(--sky);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
}
.wordmark img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-md); }
.sidebar-title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-sub { font-size: 10.5px; color: var(--sidebar-dim); margin-top: 2px; }

.sidebar-toggle {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--muted-2);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
}
.sidebar-toggle:hover { color: #fff; }

.nav-group { padding: 8px 10px 2px; }
.nav-group-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 650; letter-spacing: 0.08em;
  color: var(--sidebar-dim);
  padding: 8px 6px 4px;
  cursor: pointer;
  user-select: none;
}
.nav-group.is-closed .nav-items { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover { background: #161f3d; color: #fff; }
.nav-item.is-active { background: var(--sky); color: #fff; font-weight: 600; }
/* currentColor so the icon follows hover and the active state. Soft navigation moves
   the highlight by toggling a class, and a stroke baked into the SVG would not follow. */
.nav-item svg { flex: 0 0 16px; stroke: currentColor; }

.sidebar-foot {
  margin-top: auto;
  padding: 12px 16px 18px;
  border-top: 1px solid #1c2647;
  font-size: 11.5px;
  color: var(--sidebar-dim);
}
.sidebar-user { color: #fff; font-weight: 600; font-size: 12.5px; }
.btn-logout {
  margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0; padding: 0;
  color: #e6a3a0; font-size: 12px; cursor: pointer;
}
.btn-logout:hover { color: var(--red); }

.app.is-collapsed .sidebar-title,
.app.is-collapsed .sidebar-sub,
.app.is-collapsed .nav-group-head,
.app.is-collapsed .nav-item span,
.app.is-collapsed .sidebar-foot .sidebar-user,
.app.is-collapsed .sidebar-foot .muted-line,
.app.is-collapsed .btn-logout span { display: none; }
.app.is-collapsed .nav-item { justify-content: center; padding: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; }
.topbar .spacer { margin-left: auto; }

.content { padding: 22px 24px 48px; }

/* Screen swaps: the outgoing screen dims briefly instead of the page going blank.
   Short enough that a fast swap reads as instant, long enough to mask a slow one. */
.content.is-switching { opacity: .45; transition: opacity 90ms ease; }
.content { transition: opacity 120ms ease; }

@media (prefers-reduced-motion: reduce) {
  .content, .content.is-switching { transition: none; }
}

/* ==========================================================================
   Cards, stats, chips
   ========================================================================== */

.card-v {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.card-v + .card-v { margin-top: 16px; }
.card-title { font-size: 14px; letter-spacing: -0.01em; font-weight: 700; margin: 0 0 12px; }
.card-sub { font-size: 12px; color: var(--muted); margin: -8px 0 12px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; margin-top: 6px; }
.stat-note { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.stat.is-critical .stat-value { color: var(--red); }
.stat.is-high .stat-value { color: var(--orange); }
.stat.is-medium .stat-value { color: #b8a208; }
.stat.is-low .stat-value { color: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}
.chip:hover { border-color: var(--sky); }
.chip.is-active { border-color: var(--sky); background: var(--sky-tint); color: var(--sky-dark); }

/* ==========================================================================
   Badges — pill, 2px border matching status colour, tinted background
   ========================================================================== */

.badge-v {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 650;
  border: 1px solid var(--line);
  background: #fafafa;
  color: var(--ink);
  white-space: nowrap;
}
.badge-v.low      { border-color: var(--green);  background: var(--tint-low);      color: #1d7c3c; }
.badge-v.medium   { border-color: var(--yellow); background: var(--tint-medium);   color: #8a7a04; }
.badge-v.high     { border-color: var(--orange); background: var(--tint-high);     color: #b85f0b; }
.badge-v.critical { border-color: var(--red);    background: var(--tint-critical); color: #b3211d; }
.badge-v.info     { border-color: var(--sky);    background: var(--sky-tint);      color: var(--sky-dark); }
.badge-v.neutral  { border-color: var(--line);   background: #f6f6f6;              color: #667281; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn-v {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
}
.btn-v:hover { background: #f6f6f6; color: var(--ink); }
.btn-v.primary { background: var(--sky); border-color: var(--sky); color: #fff; }
.btn-v.primary:hover { background: var(--sky-dark); border-color: var(--sky-dark); color: #fff; }
.btn-v.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-v.danger:hover { background: #c22a25; border-color: #c22a25; color: #fff; }
.btn-v.ghost { border-color: var(--line); }
.btn-v.sm { padding: 6px 12px; font-size: 12px; }
.btn-v.block { width: 100%; justify-content: center; }
.btn-v:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0;
  color: var(--sky-dark); font-size: 13px; font-weight: 600; cursor: pointer;
  margin-bottom: 14px;
}
.btn-back:hover { color: var(--sky); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }

table.table-v { width: 100%; border-collapse: collapse; font-size: 13px; margin: 0; }
table.table-v th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: #fbfbfb;
}
table.table-v td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.table-v tbody tr:last-child td { border-bottom: 0; }
table.table-v tbody tr.clickable { cursor: pointer; }
table.table-v tbody tr.clickable:hover { background: var(--sky-tint); }
table.table-v td.id-cell { font-weight: 650; white-space: nowrap; }
table.table-v .row-empty { text-align: center; color: var(--muted); padding: 32px 14px; }

/* Overdue rows are highlighted, per the Regulatory Notifications screen */
table.table-v tbody tr.is-overdue { background: var(--tint-critical); }
table.table-v tbody tr.is-overdue:hover { background: #f9dedd; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 4px; }
.input-v, select.input-v, textarea.input-v {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
.input-v:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-tint); }
textarea.input-v { min-height: 96px; resize: vertical; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

.form-error {
  border: 1px solid var(--red);
  background: var(--tint-critical);
  color: #b3211d;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 14px;
}
.form-ok {
  border: 1px solid var(--green);
  background: var(--tint-low);
  color: #1d7c3c;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* ==========================================================================
   Detail views
   ========================================================================== */

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.detail-item .k { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-item .val { font-size: 14px; font-weight: 600; margin-top: 4px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 1px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -7px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 1px solid var(--sky);
}
.timeline .t-title { font-size: 13px; font-weight: 650; }
.timeline .t-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Info tooltip — static help copy, per README */
.info-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid var(--muted-2); color: var(--muted-2);
  font-size: 10px; font-weight: 650; cursor: help; margin-left: 5px;
  vertical-align: middle;
}
.info-tip:hover { border-color: var(--sky); color: var(--sky); }

/* ==========================================================================
   Kanban (Investigation Board)
   ========================================================================== */

.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; }
.kanban-col { background: #eceff5; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px; min-height: 200px; }
.kanban-col h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 10px; display: flex; justify-content: space-between; }
.kanban-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 10px; cursor: pointer; }
.kanban-card:hover { border-color: var(--sky); }
.kanban-card .kc-id { font-size: 10.5px; font-weight: 650; color: var(--muted); }
.kanban-card .kc-title { font-size: 12.5px; font-weight: 650; margin: 4px 0 6px; }

/* ==========================================================================
   Heat map & matrix grids
   ========================================================================== */

.heatmap { border-collapse: separate; border-spacing: 4px; font-size: 12px; }
.heatmap th { font-size: 11px; font-weight: 650; color: var(--muted); padding: 6px; text-align: left; }
.heat-cell {
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  font-weight: 650;
  border: 1px solid var(--line);
  background: #fafafa;
  color: var(--muted);
  min-width: 92px;
}
.heat-cell.low      { border-color: var(--green);  background: var(--tint-low);      color: #1d7c3c; }
.heat-cell.medium   { border-color: var(--yellow); background: var(--tint-medium);   color: #8a7a04; }
.heat-cell.high     { border-color: var(--orange); background: var(--tint-high);     color: #b85f0b; }
.heat-cell.critical { border-color: var(--red);    background: var(--tint-critical); color: #b3211d; }

/* ==========================================================================
   Misc
   ========================================================================== */

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; font-weight: 700; margin: 0; }
.section-head .spacer { margin-left: auto; }

.progress-v { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-v > span { display: block; height: 100%; background: var(--sky); }

.avatar-initials {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--sky-tint); color: var(--sky-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: 0 0 32px;
}
.org-logo { width: 32px; height: 32px; border-radius: var(--radius-sm); object-fit: cover; flex: 0 0 32px; }

.spark { display: block; }

.toast-host { position: fixed; right: 20px; bottom: 20px; z-index: 1080; display: flex; flex-direction: column; gap: 10px; }
.toast-v {
  background: var(--ink); color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 16px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-width: 380px;
}
.toast-v.err { background: var(--red); }
.toast-v.ok { background: var(--green); }

.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .app, .app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .app .sidebar-title, .app .sidebar-sub, .app .nav-group-head,
  .app .nav-item span, .app .sidebar-foot .sidebar-user,
  .app .sidebar-foot .muted-line, .app .btn-logout span { display: none; }
  .app .nav-item { justify-content: center; padding: 10px; }
  .content { padding: 16px 14px 40px; }
  .kanban { grid-template-columns: repeat(4, 260px); }
}
