/* ==========================================================================
   Workshop Quality Audit — EmiratesSkills System
   Custom CSS implementing design-tokens.json (light theme, authoritative).
   No build step: plain CSS variables + component classes.
   ========================================================================== */

:root {
  /* Brand palette (fixed) */
  --color-primary-light: #00658f;
  --color-blue: #0084ad;
  --color-blue-light: #00bbe6;
  --color-green: #b8db55;
  --color-red: #e34123;
  --color-yellow: #fee300;
  --color-gold: #ae7e30;
  --chart-1: #045884;

  /* Semantic (shadcn) tokens — light values */
  --background: #f7f7f8;
  --foreground: #1a1c23;
  --card: #ffffff;
  --card-foreground: #1a1c23;
  --popover: #ffffff;
  --primary: #003764;
  --primary-foreground: #fafafa;
  --secondary: #f1f2f4;
  --secondary-foreground: #2a2d36;
  --muted: #f1f2f4;
  --muted-foreground: #6b7280;
  --accent: #f1f2f4;
  --accent-foreground: #2a2d36;
  --destructive: #991b1b;
  --destructive-foreground: #ffffff;
  --warning: #fef08a;
  --warning-foreground: #a16207;
  --success: #bbf7d0;
  --success-foreground: #15803d;
  --border: #e5e7eb;
  --input: #e5e7eb;
  --ring: #a1a1aa;

  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --header-h: 64px;
}

* { box-sizing: border-box; border-color: var(--border); }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Noto Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--background);
  color: var(--foreground);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---- Brand stripe (4-column 4px bar) ------------------------------------ */
.brand-stripe {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 4px;
  width: 100%;
}
.brand-stripe > span:nth-child(1) { background: var(--primary); }
.brand-stripe > span:nth-child(2) { background: var(--color-blue); }
.brand-stripe > span:nth-child(3) { background: var(--color-red); }
.brand-stripe > span:nth-child(4) { background: var(--color-yellow); }

/* ---- App chrome --------------------------------------------------------- */
.app-header {
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  color: #fff;
}
.app-header .brand-logo { height: 30px; width: auto; display: block; }
.app-header .brand-divider { width: 1px; height: 26px; background: rgba(255,255,255,0.25); }
.app-header .spacer { flex: 1; }
.app-header .welcome { color: rgba(255,255,255,0.9); font-size: 0.875rem; }
.app-header .scope-pill {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}
.header-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Mobile hamburger (hidden on desktop) */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 40px; background: transparent; border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-md); cursor: pointer; padding: 0 10px;
}
.nav-toggle span { display: block; height: 2px; background: #fff; border-radius: 2px; }

/* Slide-in drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; z-index: 60;
}
.drawer-backdrop.is-open { display: block; }
.drawer {
  position: absolute; top: 0; right: 0; height: 100%; width: 280px; max-width: 82%;
  background: var(--card); box-shadow: -6px 0 20px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; padding: 1rem 1.1rem;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.drawer-user { font-weight: 600; }
.drawer-close { background: none; border: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted-foreground); }
.drawer-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.drawer-nav a { padding: 0.7rem 0.6rem; border-radius: var(--radius-md); font-weight: 500; color: var(--foreground); }
.drawer-nav a:hover { background: var(--muted); }
.drawer-logout { margin-top: auto; padding-top: 1rem; }

main.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.container-narrow { max-width: 720px; }

footer.app-footer {
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  padding: 1.5rem;
}

/* ---- Typography helpers ------------------------------------------------- */
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-foreground);
}
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.muted { color: var(--muted-foreground); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-destructive { color: var(--destructive); }
.text-success { color: var(--success-foreground); }
.font-semibold { font-weight: 600; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 2.25rem;
  padding: 0 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  background: var(--secondary);
  color: var(--secondary-foreground);
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled, .btn[disabled], .btn.is-disabled {
  opacity: 0.5; pointer-events: none; cursor: not-allowed;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-destructive { background: var(--destructive); color: #fff; }
.btn-success { background: var(--success); color: var(--success-foreground); }
.btn-warning { background: var(--warning); color: var(--warning-foreground); }
.btn-outline {
  background: transparent; border-color: var(--border); color: var(--foreground);
  box-shadow: none;
}
.btn-outline-white {
  background: transparent; border-color: rgba(255,255,255,0.25); color: #fff;
  box-shadow: none;
}
.btn-ghost { background: transparent; box-shadow: none; color: var(--foreground); }
.btn-sm { height: 2rem; padding: 0 0.7rem; font-size: 0.8125rem; }
.btn-lg { height: 2.5rem; padding: 0 1.25rem; }
.btn-icon { width: 2.25rem; padding: 0; }
.btn-block { width: 100%; }

/* ---- Cards -------------------------------------------------------------- */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-body { padding: 1.25rem; }
.card-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-title { font-size: 1.05rem; font-weight: 600; margin: 0; }
.card-accent { border-top: 4px solid var(--primary); }
.card-navy { background: var(--primary); color: #fff; border-color: var(--primary); }

/* KPI card */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 1.1rem 1.25rem;
}
.kpi .kpi-label {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8125rem; color: var(--muted-foreground);
}
.kpi .kpi-value { font-size: 1.9rem; font-weight: 700; margin-top: 0.35rem; }
a.kpi { display: block; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.kpi:hover { border-color: var(--primary); box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08); transform: translateY(-1px); }

/* ---- Badges ------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--primary); color: #fff;
}
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-destructive { background: var(--destructive); color: #fff; }
.badge-warning { background: var(--warning); color: var(--warning-foreground); }
.badge-success { background: var(--success); color: var(--success-foreground); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--foreground); }
.badge-navy { background: var(--chart-1); color: #fff; }

/* ---- Alerts ------------------------------------------------------------- */
.alert {
  display: flex; gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 0.875rem;
}
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-destructive { background: #fef2f2; border-color: #fecaca; color: var(--destructive); }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: var(--success-foreground); }

/* ---- Forms -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
label.label { font-size: 0.8125rem; font-weight: 500; }
.input, .textarea, select.input {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.7rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  font: inherit;
  color: inherit;
}
.textarea { height: auto; min-height: 5rem; padding: 0.5rem 0.7rem; resize: vertical; }
.input:focus, .textarea:focus, select.input:focus {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
  border-color: var(--ring);
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .toggle-eye {
  position: absolute; right: 0.5rem; background: none; border: none;
  cursor: pointer; color: var(--muted-foreground); padding: 0.25rem;
}

/* ---- Chips (selectable) ------------------------------------------------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.875rem;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all .12s;
}
.chip:hover { border-color: var(--primary); }
.chip.is-selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.is-disabled { opacity: 0.5; pointer-events: none; }
.chip .count { color: var(--muted-foreground); font-size: 0.8125rem; }
.chip.is-selected .count { color: rgba(255,255,255,0.75); }
/* Radio/checkbox chips (native input, no JS) */
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }

.step-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: 0.8rem; font-weight: 700;
  margin-right: 0.5rem;
}

/* ---- Stars -------------------------------------------------------------- */
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }

/* ---- Progress ----------------------------------------------------------- */
.progress { height: 0.5rem; background: var(--muted); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width .2s; }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.table thead th {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  text-align: left; font-weight: 600; padding: 0.65rem 0.85rem;
  color: var(--muted-foreground); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
table.table tbody td { padding: 0.65rem 0.85rem; border-top: 1px solid var(--border); }
table.table tbody tr:hover { background: color-mix(in srgb, var(--muted) 25%, transparent); }
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---- Tabs --------------------------------------------------------------- */
.tabs { display: inline-flex; gap: 0.25rem; background: var(--muted); padding: 0.25rem; border-radius: var(--radius-md); }
.tabs a {
  padding: 0.4rem 0.9rem; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; color: var(--muted-foreground);
}
.tabs a.is-active { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-xs); }

/* ---- Bar list ----------------------------------------------------------- */
.bar-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; }
.bar-row .bar-label { width: 180px; text-align: right; font-size: 0.875rem; font-weight: 500; flex-shrink: 0; }
.bar-track { flex: 1; height: 1.25rem; background: var(--muted); border-radius: var(--radius-sm); overflow: hidden; }
.bar-track > span { display: block; height: 100%; background: var(--chart-1); }

/* ---- Dialog ------------------------------------------------------------- */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.dialog-backdrop.is-open { display: flex; }
.dialog {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; padding: 1.25rem;
}
.dialog h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }

/* ---- Layout utilities --------------------------------------------------- */
.row { display: flex; align-items: center; gap: 0.75rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.ml-auto { margin-left: auto; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ---- Checklist rows ----------------------------------------------------- */
.checklist-row {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.85rem 1rem; border-top: 1px solid var(--border);
}
.checklist-row:first-child { border-top: none; }
.checklist-row.is-fail { background: #fef2f2; }
.checklist-row .num { color: var(--muted-foreground); width: 1.75rem; font-variant-numeric: tabular-nums; }
.checklist-row .item-main { flex: 1; }
.checklist-row .item-name { font-weight: 500; }
.checklist-row .obs-note {
  margin-top: 0.35rem; padding: 0.4rem 0.6rem; background: #fef2f2;
  border-left: 3px solid var(--destructive); border-radius: var(--radius-sm);
  font-size: 0.8125rem; color: #7f1d1d;
}
.mark-btns { display: flex; gap: 0.4rem; }
.mark-btn {
  width: 2.25rem; height: 2.25rem; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.mark-btn.ok.is-selected { background: #bbf7d0; color: #15803d; border-color: #bbf7d0; }
.mark-btn.fail.is-selected { background: var(--destructive); color: #fff; border-color: var(--destructive); }

.sticky-footer {
  position: sticky; bottom: 0; margin-top: 1rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 0.85rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}

/* ---- Result screen ------------------------------------------------------ */
.result-card { max-width: 560px; margin: 0 auto; text-align: center; }
.result-stars svg { width: 38px; height: 38px; }
.stat-row { display: flex; justify-content: center; gap: 2rem; margin: 1rem 0; }
.stat-row .stat .v { font-size: 1.4rem; font-weight: 700; }
.stat-row .stat .l { font-size: 0.8rem; color: var(--muted-foreground); }

/* ==========================================================================
   Login split layout
   ========================================================================== */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 55% 45%; }
.login-left {
  background: var(--primary); color: #fff; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; padding: 3rem;
}
.login-brand { text-align: center; max-width: 80%; }
.login-logo { width: 100%; max-width: 460px; height: auto; display: block; margin: 0 auto; }
.login-subtitle {
  margin-top: 1.25rem; font-size: 1.15rem; font-weight: 600; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.beta {
  background: var(--color-yellow); color: #1a1c23; font-weight: 700;
  font-size: 0.7rem; padding: 0.15rem 0.55rem; border-radius: 999px; letter-spacing: .03em;
}
.login-left .cube-pattern {
  position: absolute; bottom: 0; left: 0;
  width: 300px; height: auto; pointer-events: none;
}
.login-right { background: #fff; position: relative; display: flex; flex-direction: column; }
.login-form { max-width: 380px; margin: auto; width: 100%; padding: 2rem 2.5rem; }
.login-heading { font-size: 1.9rem; font-weight: 700; margin: 0 0 .75rem; color: var(--foreground); }
.login-rule { border: none; border-top: 1px solid var(--border); margin: 0 0 1.5rem; }
.req { color: var(--color-red); }
@media (max-width: 800px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { min-height: 300px; }
  .login-left .cube-pattern { width: 200px; }
}

/* ==========================================================================
   Responsive / mobile
   ========================================================================== */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }

  .app-header { padding: 0 0.9rem; gap: 0.6rem; }
  .brand-title, .brand-divider, .app-header .scope-pill { display: none; }
  .brand-logo { height: 26px; }
  .header-actions { display: none; }
  .nav-toggle { display: flex; }

  main.container { padding: 1rem 0.9rem 2.5rem; gap: 1rem; }

  /* KPI cards: two shrinkable columns (minmax 0 prevents overflow on phones) */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .kpi-value { font-size: 1.55rem; }

  .row-between { flex-wrap: wrap; gap: 0.6rem; }
  .card-header { flex-wrap: wrap; gap: 0.6rem; }

  /* Rating-by-campus bars: let rows wrap instead of overflowing */
  .bar-row { flex-wrap: wrap; }
  .bar-row .bar-label { width: 100%; text-align: left; }
  .bar-row .bar-track { flex: 1 1 120px; }

  /* Segmented tabs scroll horizontally rather than overflow the page */
  .tabs { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs a { white-space: nowrap; }

  /* Wide tables marked .table-cards render as stacked cards on mobile */
  .table-wrap:has(.table-cards) { border: none; overflow: visible; }
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--card); box-shadow: var(--shadow-xs);
    padding: 0.5rem 0.85rem; margin-bottom: 0.65rem;
  }
  .table-cards td {
    border: none; padding: 0.35rem 0;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    text-align: right;
  }
  .table-cards td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--muted-foreground);
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
    text-align: left; flex-shrink: 0;
  }
  /* Action cell (no label): full-width buttons */
  .table-cards td[data-label=""] { justify-content: stretch; padding-top: 0.6rem; }
  .table-cards td[data-label=""]::before { display: none; }
  .table-cards td[data-label=""] .btn { flex: 1; }

  /* Result & stat rows breathe on small screens */
  .stat-row { gap: 1.25rem; }
}

/* ==========================================================================
   Print / PDF — only the .document should show
   ========================================================================== */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .document { box-shadow: none; border: none; }
}
