/* Self-hosted Work Sans (variable weight 100–900), so the UI font works offline
   and in the field without a dependency on Google's CDN. latin + latin-ext cover
   English plus accented names. */
@font-face {
  font-family: "Work Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/work-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Work Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/work-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Changa One — display face used only for the WorkGauge wordmark/logo. */
@font-face {
  font-family: "Changa One";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/changa-one-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Brand constants — identical in both themes. */
  --white: #ffffff;
  --blue: #3b82f6;
  --blue-grad: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

/* Theme palettes. Dark is the default; base.html sets data-bs-theme on <html>
   before paint (from localStorage / system preference) and the toggle flips it.
   Bootstrap reads the --bs-* vars; our own components read the semantic tokens
   (--text, --heading, --badge-bg, …). Our rules still win because this file
   loads after bootstrap.css. */
[data-bs-theme="dark"] {
  --bg: #0b1726;
  --card: #122036;
  --border: #1e314d;
  --hover: #182844;
  --muted: #9ca3af;
  --dim: #6b7280;
  --faint: #4b5563;
  --text: #e5e7eb;
  --heading: #ffffff;
  --badge-bg: #1e3a5f;

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-body-font-family: "Work Sans", system-ui, sans-serif;
  --bs-emphasis-color: var(--heading);
  --bs-emphasis-color-rgb: 255, 255, 255;
  --bs-secondary-color: var(--muted);
  --bs-tertiary-color: var(--dim);
  --bs-border-color: var(--border);
  --bs-border-color-translucent: var(--border);
  --bs-primary: var(--blue);
  --bs-primary-rgb: 59, 130, 246;
  --bs-link-color: var(--text);
  --bs-link-hover-color: var(--heading);
}

[data-bs-theme="light"] {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #d7dce6;
  --hover: #eef1f7;
  --muted: #5b6472;
  --dim: #6b7280;
  --faint: #8b95a5;
  --text: #1f2937;
  --heading: #0b1726;
  --badge-bg: #dbeafe;

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-body-font-family: "Work Sans", system-ui, sans-serif;
  --bs-emphasis-color: var(--heading);
  --bs-emphasis-color-rgb: 11, 23, 38;
  --bs-secondary-color: var(--muted);
  --bs-tertiary-color: var(--dim);
  --bs-border-color: var(--border);
  --bs-border-color-translucent: var(--border);
  --bs-primary: var(--blue);
  --bs-primary-rgb: 59, 130, 246;
  --bs-link-color: var(--text);
  --bs-link-hover-color: var(--heading);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Work Sans", system-ui, sans-serif;
}

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

/* ── Top bar ── */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;          /* wrap instead of overflowing on small screens */
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.brand-logo img, .brand-logo svg { height: 100%; width: auto; display: block; }
.brand-name { color: var(--heading); font-size: 16px; font-weight: 700; }
/* WorkGauge wordmark: display font, scoped to the .brand logo so it does not
   affect the employee-name header that reuses .brand-name on its own. */
.brand .brand-name {
  font-family: "Changa One", sans-serif;
  font-weight: 400;
  font-size: 25px;
  line-height: 1;
}
.badge {
  color: var(--blue); background: var(--badge-bg);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.spacer { margin-left: auto; }
/* Pinned header: applied via the `sticky` modifier on the HR dashboard and
   employee-detail topbars, so the bar stays in view while the page scrolls.
   (Sits above page content but below the theme toggle at z-index 1050.) */
.topbar.sticky { position: sticky; top: 0; z-index: 1030; }

/* ── Layout ── */
.container { max-width: 1000px; margin: 32px auto; padding: 0 20px; }
.container.narrow { max-width: 720px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.card-pad { padding: 24px; }
.card-head {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  color: var(--heading); font-size: 15px; font-weight: 700;
}

/* ── Buttons ── */
.btn {
  border: none; border-radius: 10px; padding: 10px 18px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--blue-grad); color: #fff; }
.btn-ghost { background: var(--border); color: var(--muted); }
.btn-ghost:hover { background: var(--border); color: var(--heading); }
.btn-danger { background: #f87171; color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 14px; font-size: 14px; }

/* ── Stat cards ──
   Layout is handled by Bootstrap's grid (.row/.col-*) in the templates; these
   rules only style the card itself. .h-100 on the col keeps them equal height. */
.stat-card {
  display: block;            /* so the card also boxes correctly as an <a> link */
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; height: 100%;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 8px 24px rgba(59, 130, 246, 0.25);
}
.stat-label { color: var(--heading); font-size: 12px; margin-bottom: 10px; }
.stat-value { font-size: 30px; font-weight: 700; }
/* Stat cards link to a breakdown page. (.stat-card already lifts on hover.) */
.stat-clickable { cursor: pointer; }
.stat-clickable:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ── Standing breakdown page (donut pie + legend) ── */
.bd-chart { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }

/* Donut: conic-gradient ring (set inline) with a card-colored hole + total. */
.bd-pie { position: relative; width: 180px; height: 180px; border-radius: 50%; flex-shrink: 0; }
.bd-pie-hole {
  position: absolute; inset: 32px; border-radius: 50%; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.bd-pie-hole span { font-size: 30px; font-weight: 700; color: var(--heading); line-height: 1; }
.bd-pie-hole small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

.bd-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 220px; }
.bd-legend li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; font-size: 14px; border-bottom: 1px solid var(--hover);
}
.bd-legend li:last-child { border-bottom: none; }
.bd-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.bd-legend .bd-lg-label { color: var(--text); }
.bd-legend .bd-lg-label:hover { color: var(--heading); text-decoration: underline; }
.bd-legend .bd-lg-val { margin-left: auto; color: var(--muted); }

/* ── Monthly trend (stacked bars + tooltip) — lives in a half-width card ── */
.trend { position: relative; }
.trend-bars { display: flex; align-items: flex-end; gap: 8px; height: 200px; }
.trend-bar {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; cursor: default; outline: none;
}
.trend-bar .trend-stack {
  flex: 1; display: flex; flex-direction: column-reverse;   /* good at the bottom */
  border-radius: 4px; overflow: hidden; background: var(--hover); min-height: 2px;
}
.trend-bar:hover .trend-stack, .trend-bar:focus-visible .trend-stack {
  outline: 2px solid var(--blue); outline-offset: 1px;
}
/* A month with no recorded history: transparent (no green), just an outline so
   the bar's shape still reads. inset shadow avoids any layout shift. */
.trend-bar.no-data .trend-stack {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--border);
}
.trend-seg { width: 100%; }
.trend-label { text-align: center; color: var(--muted); font-size: 11px; margin-top: 6px; }
.trend-year { display: block; color: var(--faint); font-size: 9px; line-height: 1.3; }

.trend-tip {
  position: absolute; transform: translate(-50%, -100%); margin-top: -8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; min-width: 150px; pointer-events: none;
  /* Above the sticky header (1030) so the popup is never clipped; below the theme toggle (1050). */
  z-index: 1040;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.trend-tip[hidden] { display: none; }
.trend-tip-head { color: var(--heading); font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.trend-tip-row { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; color: var(--muted); padding: 2px 0; }
.trend-tip-empty { justify-content: center; color: var(--faint); font-style: italic; }

@media (max-width: 576px) {
  .trend-bars { gap: 4px; height: 160px; }
  .trend-label { font-size: 9px; }
}

/* ── Standing alert + roll-over (employee /me view) ──
   The banner's accent border-left color and subtle background are set inline
   per standing (good / warning / suspended); these rules carry the layout. */
.alert-banner {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 20px;
}
.alert-banner .alert-icon { font-size: 18px; line-height: 1.4; flex-shrink: 0; }
.alert-banner .alert-body { flex: 1; }
.alert-banner .alert-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.alert-banner .alert-msg { color: var(--text); font-size: 13px; line-height: 1.55; }
.alert-banner .alert-sub { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 6px; }

.rollover { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.rollover .rollover-label {
  color: var(--muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; flex-shrink: 0;
}
.rollover .rollover-body { color: var(--text); font-size: 13px; line-height: 1.5; }
.rollover .rollover-body strong { color: var(--heading); }

/* ── Pills ── */
.pill { border-radius: 20px; padding: 4px 12px; font-size: 11px; font-weight: 700; display: inline-block; }

/* ── Filters ── */
.filters { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.dept-filter { position: relative; display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 20px; }
/* Google-style pill: rounded field with the magnifying glass tucked inside on the right. */
.emp-search-wrap { position: relative; display: flex; align-items: center; }
.emp-search {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 42px 10px 18px; color: var(--text);
  font-size: 13px; outline: none; font-family: inherit;
  width: 440px; max-width: 100%;
}
.emp-search:focus { border-color: var(--blue); }
.emp-search-icon {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
@media (max-width: 640px) {
  .dept-filter { flex-direction: column; gap: 10px; }
}
.chip {
  background: var(--card); color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 14px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.chip.active { background: var(--blue); color: #fff; border-color: transparent; }

/* Empty state shown when a search matches no employees. */
.emp-empty { padding: 28px 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── Pagination ──
   Skin override on Bootstrap's .pagination: centered, separated rounded pills in
   the dark palette, app-blue active page. Selectors are scoped under .pagination
   so they out-specify Bootstrap's base rules. .emp-pagination wraps the JS-built
   control and just provides top spacing. */
.emp-pagination { margin-top: 18px; }
.pagination {
  display: flex; justify-content: center; gap: 6px;
  list-style: none; padding: 0; margin: 0; flex-wrap: wrap;
}
.pagination .page-item .page-link {
  margin: 0; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--muted);
  padding: 8px 14px; font-size: 13px; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.pagination .page-item .page-link:hover { background: var(--border); color: var(--heading); }
.pagination .page-item.active .page-link {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
.pagination .page-item.disabled .page-link {
  color: var(--faint); background: var(--card); cursor: default; opacity: .6;
}
.pagination .page-link:focus { outline: none; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4); }

/* ── Collapsible cards (fold/expand audit history) ── */
details.card > summary.card-head { cursor: pointer; list-style: none; }
details.card > summary.card-head::-webkit-details-marker { display: none; }
details.card > summary.card-head::before {
  content: "\25B8"; display: inline-block; margin-right: 8px;
  color: var(--muted); transition: transform .15s;
}
details.card[open] > summary.card-head::before { transform: rotate(90deg); }

/* Audit Log employee combobox */
.audit-filter { max-width: 360px; }

/* ── Employee rows ──
   Each row is a Bootstrap grid (.row/.col-*) inside .emp-row, so it reflows to a
   stacked card on phones and a single line on desktop. .emp-row only carries the
   divider + hover; the column layout comes from Bootstrap. */
.emp-row {
  display: block;
  padding: 16px 24px;
  border-bottom: 1px solid var(--hover);
}
.emp-row:last-child { border-bottom: none; }
.emp-row:hover { background: var(--hover); }
/* Column header above the list (desktop only; hidden on phones via d-none). */
.row-head {
  padding: 14px 24px; border-bottom: 1px solid var(--hover);
  color: var(--muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.who { display: flex; align-items: center; gap: 12px; }
.who .name { color: var(--text); font-size: 14px; font-weight: 600; }
.who .sub { color: var(--faint); font-size: 11px; }

/* ── Progress ── */
.progress { background: var(--bg); border-radius: 99px; height: 6px; overflow: hidden; }
.progress.lg { height: 10px; }
.progress > span { display: block; height: 100%; border-radius: 99px; }
.pts-line { display: flex; justify-content: space-between; margin-bottom: 4px; }
.pts-line .v { color: var(--heading); font-size: 13px; font-weight: 700; }
.pts-line .max { color: var(--muted); font-size: 11px; }

/* ── Incident list ── */
.inc {
  padding: 16px 24px; border-bottom: 1px solid var(--hover);
  display: flex; align-items: center; gap: 14px;
}
.inc:last-child { border-bottom: none; }
.inc.expired { opacity: 0.5; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.inc .body { flex: 1; }
.inc .body .t { color: var(--text); font-size: 14px; font-weight: 600; }
.inc .body .n { color: var(--dim); font-size: 12px; }
.inc .amt { text-align: right; }
.inc .amt .p { font-weight: 700; }
.inc .amt .d { color: var(--faint); font-size: 11px; }
.tag-expired { color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }

/* ── Forms ── */
.field { margin-bottom: 16px; }
.field label { color: var(--muted); font-size: 12px; display: block; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; color: var(--text); font-size: 14px;
  outline: none; font-family: inherit;
}
.field textarea { resize: vertical; }
/* CSV import: file picker and Import button sit side by side, file box sized to content. */
.import-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.import-row input[type="file"] {
  width: 240px; max-width: 100%;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; color: var(--text); font-size: 13px;
  outline: none; font-family: inherit;
}

details.logbox { margin-bottom: 20px; }
details.logbox > summary {
  list-style: none; cursor: pointer; display: inline-flex;
}
details.logbox > summary::-webkit-details-marker { display: none; }
.logform { margin-top: 14px; max-width: 460px; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 420px; }
.login-head { text-align: center; margin-bottom: 40px; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 32px; }
.role-grid { display: flex; gap: 12px; }
.role-grid .btn { flex: 1; }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.center { text-align: center; }

/* ── Theme toggle ──
   Fixed floating button on every page (added in base.html). Shows a sun in dark
   mode (click → light) and a moon in light mode (click → dark). */
.theme-toggle {
  position: fixed; left: 18px; bottom: 18px; z-index: 1050;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); font-family: inherit;
  transition: transform .15s ease, border-color .15s ease;
}
.theme-toggle:hover { transform: translateY(-2px); border-color: var(--blue); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
[data-bs-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-bs-theme="light"] .theme-toggle .icon-moon { display: inline; }

/* ════════════════════════════════════════════════════════════════
   Responsive tuning for phones (≤ 576px / Bootstrap's `sm` and below).
   Bootstrap's grid already reflows the columns; these only tighten
   spacing and type so nothing feels cramped or overflows on a phone.
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 576px) {
  .topbar { padding: 12px 16px; }
  .container { margin: 18px auto; padding: 0 14px; }
  .card-pad { padding: 16px; }
  .card-head { padding: 16px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 24px; }
  .emp-row { padding: 14px 16px; }
  .inc { padding: 14px 16px; }
  .logform { max-width: 100%; }
  .login-card { padding: 24px; }
}

/* ════════════════════════════════════════════════════════════════
   Print / "Export PDF" — the export buttons call window.print(); these
   rules turn the on-screen (dark-tuned) record into a clean, ink-light
   one-page document: interactive chrome is dropped, a titled header is
   shown, and only the standing pill / progress bar / type dots keep color.
   ════════════════════════════════════════════════════════════════ */
.print-header { display: none; }   /* hidden on screen; shown only when printing */

@media print {
  @page { margin: 14mm; }

  /* Ink-light palette regardless of the on-screen theme. */
  :root,
  [data-bs-theme="dark"],
  [data-bs-theme="light"] {
    --bg: #fff; --card: #fff; --border: #cbd2dc; --hover: #eef1f7;
    --muted: #374151; --dim: #4b5563; --faint: #6b7280;
    --text: #111827; --heading: #000;
  }
  body { background: #fff !important; color: #111827 !important; }

  /* Drop everything interactive / screen-only. */
  .topbar,
  .theme-toggle,
  details.logbox,
  details.card,            /* audit history (HR page) — internal, kept off the record */
  .inc .editbox,
  .alert-banner,           /* on-screen standing guidance — numbers stay in the cards */
  .rollover,
  .trend,                  /* interactive chart — screen only */
  form { display: none !important; }

  /* The titled document header replaces the screen top bar. */
  .print-header { display: block !important; margin-bottom: 18px;
    padding-bottom: 10px; border-bottom: 2px solid #000; }
  .print-header .print-title { font-size: 18px; font-weight: 700; color: #000; }
  .print-header .print-meta { font-size: 12px; color: #374151; margin-top: 4px; }

  /* Full-width, flat cards that don't split across a page break. */
  .container { margin: 0 auto !important; max-width: 100% !important; padding: 0 !important; }
  .card { border: 1px solid var(--border) !important; box-shadow: none !important; }
  .card, .inc, .stat-card { break-inside: avoid; }

  /* Keep only the standing pill, progress bar, and type dots in color. */
  .pill, .progress, .progress > span, .dot {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  /* Inline-colored headline numbers / point amounts → dark for legibility on
     white (incident type stays clear from its text label and colored dot). */
  .stat-value, .inc .amt .p { color: #111827 !important; }
}
