/*
 * ui-tokens.css
 * Design tokens + shared component styles for the SQA MIS UI redesign.
 * Loaded after the theme (Cosmo/Bootstrap) CSS and before mystyle.css, so
 * mystyle.css's per-component overrides (which now reference these tokens)
 * still win the cascade exactly as before.
 *
 * Scope: visual only. Nothing here changes markup, form field names, POST
 * targets, or JS behaviour on the pages that use it.
 */

:root {
  /* Brand */
  --primary: #4378a4;
  --primary-hover: #35648a;
  --primary-active: #2c5474;
  --primary-tint: #e9f0f6;
  --primary-dark: #2f5b7a;

  /* Neutrals */
  --ink: #1e232b;
  --ink-soft: #4a5158;
  --muted: #7a8087;
  --surface: #f6f4ef;
  --surface-alt: #ffffff;
  --border: #ded8c9;

  /* Status */
  --success: #2f7d54;
  --success-hover: #256844;
  --success-tint: #e5f2ea;
  --warning: #a3730f;
  --warning-tint: #f8eed8;
  --danger: #a83b3b;
  --danger-hover: #8f3131;
  --danger-tint: #f7e6e6;
  --secondary: #5b6b78;
  --secondary-hover: #48555f;
}

/* ---------------------------------------------------------------------
 * Cards — Bootstrap's .card is already used throughout (e.g. arr_all.php);
 * this only refines border/spacing so stacked cards read as a system.
 * ------------------------------------------------------------------- */
.card {
  border-color: var(--border);
  border-radius: 8px;
}
.card + .card {
  margin-top: 1rem;
}
.card-header {
  background-color: var(--primary-tint);
  border-bottom-color: var(--border);
  font-weight: 600;
  color: var(--primary-dark);
}

/* ---------------------------------------------------------------------
 * Status pill — a compact colored label for a case's current status,
 * used in place of (or alongside) plain status text. Apply by wrapping
 * existing PHP-echoed status/decision text with one of these classes,
 * chosen from data already available on the page ($decision/$status) —
 * no new queries, no changed values.
 * ------------------------------------------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.6;
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}
.status-pill-progress {
  background: var(--primary-tint);
  color: var(--primary-dark);
}
.status-pill-success {
  background: var(--success-tint);
  color: var(--success);
}
.status-pill-warning {
  background: var(--warning-tint);
  color: var(--warning);
}
.status-pill-danger {
  background: var(--danger-tint);
  color: var(--danger);
}

/* ---------------------------------------------------------------------
 * Step pills — visual refinement of the existing "nav nav-pills" tab bar
 * used by every module's *_header.php (Main/Attachments/.../Status).
 * Same <ul class="nav nav-pills">/<a class="nav-link"> markup, same
 * onclick submit() wiring — CSS only.
 * ------------------------------------------------------------------- */
.nav-pills.step-pills {
  gap: 6px;
  flex-wrap: wrap;
}
.nav-pills.step-pills .nav-link {
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.nav-pills.step-pills .nav-link:hover {
  background: var(--primary-tint);
  color: var(--primary-dark);
}
.nav-pills.step-pills .nav-link.active {
  background: var(--primary) !important;
  border-color: var(--primary);
  color: #fff;
}
.nav-pills.step-pills .badge {
  font-weight: 700;
}

/* Case header panel — wraps the existing page-header row (title,
 * breadcrumb, status, action buttons) from *_header.php in a card-style
 * band, no change to the buttons/forms inside it. */
.case-header-panel {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px 8px;
  margin-bottom: 16px;
}
.case-header-panel h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.case-header-panel h5 {
  color: var(--muted);
  font-size: 0.85rem;
}
.case-header-panel .progress {
  border-radius: 999px;
  overflow: hidden;
}

/* ---------------------------------------------------------------------
 * Responsive table -> stacked card. Opt in per table with
 * class="table-modern" — same <table>/<thead>/<tbody> markup, same
 * columns and data, no JS/query change. Below 700px, each row becomes
 * a bordered card and header cells become inline labels using each
 * cell's data-label attribute (falls back gracefully with none).
 * ------------------------------------------------------------------- */
@media (max-width: 700px) {
  table.table-modern thead {
    display: none;
  }
  table.table-modern,
  table.table-modern tbody,
  table.table-modern tr,
  table.table-modern td {
    display: block;
    width: 100%;
  }
  table.table-modern tr {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 6px 12px;
  }
  table.table-modern td {
    border: none;
    padding: 6px 0;
    text-align: left !important;
  }
  table.table-modern td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
    display: block;
  }
  table.table-modern td[style*="display:none"],
  table.table-modern td[style*="display: none"] {
    display: none !important;
  }
}

/* ---------------------------------------------------------------------
 * File upload — visual treatment for the existing <input type="file">
 * elements. Same name/id/accept attributes, same server-side handling.
 * ------------------------------------------------------------------- */
.upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface);
}
.upload-dropzone input[type="file"] {
  background: transparent;
  border: none;
}
.upload-dropzone small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------------------------------------------------------------------
 * Decision consequence callout — informational note only, no logic.
 * ------------------------------------------------------------------- */
.decision-callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #ecd9ab;
  background: var(--warning-tint);
  color: #6b4d0b;
  font-size: 13px;
  line-height: 1.5;
  margin: 10px 0 16px;
}
.decision-callout strong {
  color: #6b4d0b;
}

/* ---------------------------------------------------------------------
 * Inline error banner — refines the existing plain-text
 * <p class="text-danger" id="err*"></p> pattern. Same element, same id,
 * JS still just sets .innerHTML; this only styles it when non-empty.
 * ------------------------------------------------------------------- */
p.text-danger:not(:empty) {
  display: block;
  background: var(--danger-tint);
  color: var(--danger) !important;
  border: 1px solid #e3bcbc;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 13.5px;
}
span.badge.badge-danger:not(:empty) {
  display: inline-block;
  background-color: var(--danger) !important;
  padding: 6px 12px;
  border-radius: 999px;
}

/* ---------------------------------------------------------------------
 * Nav multi-level dropdown-submenu — relocated verbatim from the inline
 * <style> block that used to live in includes/php/navigation_bar.php.
 * Same selectors, same rules; centralized here per the redesign plan.
 * ------------------------------------------------------------------- */
.dropdown-submenu {
  position: relative;
}

.dropdown-submenu a::after {
  transform: rotate(-90deg);
  position: absolute;
  right: 6px;
  top: .8em;
}

.dropdown-submenu .dropdown-menu {
  top: 0;
  left: 100%;
  margin-left: .1rem;
  margin-right: .1rem;
}
