/* ============================================================
   Shared design system
   Built on top of Bootstrap 5 (loaded before this file on every
   page). Only overrides / additions live here so every page
   (login, register, dashboard, invitees) looks consistent and
   no page repeats its own copy of these rules.
   ============================================================ */

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --border: #E1E4E9;
  --text: #1B1F27;
  --text-muted: #667085;
  --text-faint: #94A3B8;

  --accent: #2454E6;
  --accent-hover: #1B3FBF;
  --accent-soft: #EEF2FF;

  --success: #0F9D63;
  --success-bg: #E8F8F1;
  --warning: #E08A2C;
  --warning-bg: #FDF3E7;
  --danger: #E0483E;
  --danger-bg: #FDECEA;

  --ghost: #4B5563;
  --ghost-bg: #EEF0F3;
  --ghost-bg-hover: #E3E6EB;

  --term-bg: #1a1a1c;
  --term-text: #C9D1D9;
  --term-accent: #4ADE80;
  --term-error: #F87171;

  --radius-sm: 6px;
  --radius: 10px;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.06);

  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Base reset — applies on every page (login, register, dashboard,
   invitees). Previously only register.css set width/margin/overflow,
   so every other page was relying on browser defaults and could
   scroll horizontally or show a background "seam" past 100% width.
   This is the single source of truth; page-specific stylesheets
   should only override what genuinely differs for that page. */
html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

html {
  background: var(--bg);
}

/* body is a 100vh flex column so that any .app-navbar sitting above
   .center-shell keeps its own natural height, and .center-shell (flex: 1
   below) fills exactly the space left over — instead of .center-shell's
   own 100vh being added on top of the navbar's height, which is what
   pushed everything down / caused the page to scroll past one viewport. */
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: opacity .15s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); }

/* ---------- App nav bar (index.html / invitees.html) ---------- */
.app-navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-navbar .brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-navbar .brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.app-navbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.app-navbar nav a {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: background .12s ease, color .12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.app-navbar nav a svg { width: 14px; height: 14px; flex-shrink: 0; }
.app-navbar nav a:hover { background: var(--ghost-bg); color: var(--text); }
.app-navbar nav a.active { background: var(--accent-soft); color: var(--accent); }
.app-navbar .navbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Layout shells ---------- */
/* Shared content shell for the two data-heavy admin pages
   (dashboard.html, invitees.html) — both should reference this
   exact class rather than each defining their own container, or
   they end up with different widths/padding and visibly different
   margins. 1180px previously left a lot of empty gutter on wide
   monitors for pages that are mostly stat cards and data tables;
   1440px keeps text content readable while giving tables more
   breathing room. */
.app-shell {
  width: 100vw;
  margin: 10px auto;
  padding: 10px 20px 60px;
}

.center-shell {
  flex: 1 1 auto;
  min-height: 0; /* let flexbox shrink it below content size instead of it forcing extra page height */
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* ---------- Buttons (extend Bootstrap) ---------- */
.btn-brand {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-ghost {
  background: var(--ghost-bg);
  border-color: var(--border);
  color: var(--ghost);
}
.btn-ghost:hover { background: var(--ghost-bg-hover); color: var(--ghost); }

.btn-emerald { background: var(--success); border-color: var(--success); color: #fff; }
.btn-emerald:hover:not(:disabled) { background: #047857; border-color: #047857; color: #fff; }
.btn-amber { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-amber:hover:not(:disabled) { background: #B45309; border-color: #B45309; color: #fff; }
.btn-rose { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-rose:hover:not(:disabled) { background: #BE123C; border-color: #BE123C; color: #fff; }

/* Buttons with a leading/trailing icon */
.btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.btn-icon svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Explicit, variant-independent sizing so every small button — ghost,
   brand, emerald, amber, rose — renders with identical type size and
   weight. Guards against any perceived inconsistency between a
   colored button and a neutral one. */
.btn.btn-sm {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

/* Icon-only button, e.g. a per-row delete action in a table */
.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}
.btn-icon-only:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-icon-only svg { width: 14px; height: 14px; }

/* Danger zone panel (destructive/irreversible actions) */
.danger-zone {
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.danger-zone h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--danger);
  margin: 0 0 4px;
}
.danger-zone h3 svg { width: 16px; height: 16px; }
.danger-zone p { font-size: 12.5px; color: var(--text-muted); margin: 0 0 12px; }
.danger-zone .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Narrow, centered card used for login / reset-password panels —
   replaces the inline max-width/width styles that were previously
   repeated on each card in index.html. */
.auth-card {
  max-width: 420px;
  width: 100%;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }

.stat-invited::before    { background: var(--accent); }
.stat-registered::before { background: var(--success); }
.stat-female::before     { background: #ff2f8d; }
.stat-pending::before    { background: var(--danger); }
.stat-walkin::before     { background: var(--warning); }

/* ---------- Badges ---------- */
.badge-invited { background: var(--accent); }
.badge-walkin  { background: var(--warning); }

/* ---------- Terminal / status log ---------- */
.log-terminal {
  background: var(--term-bg);
  color: var(--term-text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
}
.log-terminal::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--term-accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}
.log-terminal.is-error::before {
  background: var(--term-error);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
}

/* ---------- Data table ---------- */
/* Kantumruy Pro renders Khmer names/text correctly; load it via
   <link href="https://fonts.googleapis.com/css2?family=Kantumruy+Pro..."> 
   in any page that includes a .data-table (already done in
   index.html and invitees.html). */
.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 12.5px; font-family: 'Kantumruy Pro', var(--sans); }
.data-table thead th {
  position: sticky; top: 0;
  background: #FAFBFC;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #FAFBFC; }
.data-table .empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Actions/trash column — same header+cell treatment wherever a
   per-row delete button appears (index.html and invitees.html). */
.data-table th.actions-col, .data-table td.actions-col {
  text-align: center;
  width: 1%;
  white-space: nowrap;
}
.actions-wrap {
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* ---------- Employee verification card (register flow) ---------- */
.employee-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  background: #FAFBFD;
}
.employee-card .ec-name { font-weight: 700; font-size: 1.3rem; color: var(--text); margin: 0 0 2px; }
.employee-card .ec-position { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 10px; }
.employee-card .ec-rule { width: 40px; height: 3px; background: var(--accent); border: none; border-radius: 2px; margin: 0 0 12px; }
.employee-card .ec-details { display: grid; grid-template-columns: 1fr 1fr; row-gap: 10px; column-gap: 14px; margin: 0; }
.employee-card dt { font-size: 0.72rem; color: var(--text-muted); margin: 0 0 2px; font-weight: 500; }
.employee-card dd { font-size: 0.9rem; color: var(--text); font-weight: 600; margin: 0; }

.success-icon-container {
  width: 64px; height: 64px;
  background-color: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem auto;
}

.closed-icon-container {
  width: 64px; height: 64px;
  background-color: var(--ghost-bg);
  color: var(--ghost);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem auto;
}

.req-text { color: var(--danger); }

/* ---------- Dropzone (invitees uploader) ---------- */
.dropzone {
  border: 2px dashed var(--text-faint);
  border-radius: var(--radius);
  background: #F8FAFC;
  transition: background .15s ease, border-color .15s ease, padding .2s ease;
  padding: 2.25rem;
  text-align: center;
}
.dropzone:hover { background: var(--ghost-bg-hover); border-color: var(--ghost); }
.dropzone label { cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; }
.dropzone svg { width: 2.5rem; height: 2.5rem; color: var(--text-faint); }
.dropzone.compact {
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dropzone.compact label { flex-direction: row; gap: .55rem; }
.dropzone.compact svg { width: 1.15rem; height: 1.15rem; }
.dropzone.compact .secondary { display: none; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 50;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 28rem;
  width: 100%;
}
.modal-box h3 { font-size: 1.125rem; font-weight: 600; margin: 0 0 1rem 0; }
.modal-box .modal-body { font-size: 0.875rem; color: var(--text); white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; padding-top: 1.25rem; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.font-mono { font-family: var(--mono); }
.text-muted-soft { color: var(--text-muted); }

@media (max-width: 560px) {
  .app-shell { padding: 20px 14px 48px; }
}
