/* ═══════════════════════════════════════════════════════════════════════════
   GATE CONTROL SYSTEM — BASE.CSS
   Layout, resets, grid, scrollbar, utility classes.
   DO NOT EDIT for look & feel changes — edit theme.css instead.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── RESET ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--weight-semi);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

p { margin: 0; }

a {
  color: var(--color-teal);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}
a:hover { opacity: 0.8; }

img, svg { display: block; max-width: 100%; }

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

input, select, textarea {
  font-family: var(--font-sans);
  font-size: var(--text-base);
}

input:focus, select:focus, textarea:focus { outline: none; }

/* ── SCROLLBAR ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb        { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover  { background: var(--scrollbar-thumb-hover); }

/* ── APP SHELL ────────────────────────────────────────────────────────────── */
#app {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}
#app.active { display: flex; }

/* ── TOPBAR ───────────────────────────────────────────────────────────────── */
.gc-topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  gap: var(--space-4);
  transition: background var(--transition-slow), border-color var(--transition-slow);
}

.gc-topbar__brand {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--color-teal);
  white-space: nowrap;
}

.gc-topbar__sep {
  width: 1px;
  height: 18px;
  background: var(--border-default);
  flex-shrink: 0;
}

.gc-topbar__gate {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.gc-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: auto;
}

.gc-topbar__clock {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-teal);
  letter-spacing: 0.05em;
}

.gc-topbar__count {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  background: var(--color-teal-dim);
  border: 1px solid var(--color-teal-border);
  border-radius: var(--radius-full);
  padding: 2px 10px;
}

.gc-topbar__user {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── PULSE DOT (live indicator) ───────────────────────────────────────────── */
.gc-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-green);
  box-shadow: 0 0 6px var(--color-green);
  flex-shrink: 0;
  animation: gc-pulse-anim 2s infinite;
}
@keyframes gc-pulse-anim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.85); }
}

/* ── SIDEBAR (HR Admin) ───────────────────────────────────────────────────── */
.gc-sidebar {
  width: var(--sidebar-width);
  min-height: calc(100vh - var(--topbar-height));
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: var(--space-4) 0;
  transition: background var(--transition-slow);
}

.gc-sidebar__section {
  padding: var(--space-3) var(--space-4) var(--space-2);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
}

.gc-sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
  user-select: none;
}
.gc-sidebar__item:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.05);
}
.gc-sidebar__item.active {
  color: var(--color-teal);
  background: rgba(0, 196, 180, 0.08);
  border-left-color: var(--color-teal);
}
.gc-sidebar__item .icon { font-size: 15px; flex-shrink: 0; }

.gc-sidebar__badge {
  margin-left: auto;
  background: var(--color-red);
  color: white;
  font-size: 9px;
  font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-family: var(--font-mono);
  min-width: 20px;
  text-align: center;
}

/* ── MAIN CONTENT WRAPPER ─────────────────────────────────────────────────── */
.gc-content {
  flex: 1;
  padding: var(--space-5);
  min-width: 0;
  overflow-x: hidden;
}

.gc-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--topbar-height));
}

/* ── PAGE SECTIONS ────────────────────────────────────────────────────────── */
.gc-page { display: none; }
.gc-page.active { display: block; }

.gc-page-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.gc-page-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-5);
}

/* ── NAV TABS (Guard portal) ──────────────────────────────────────────────── */
.gc-tabs {
  display: flex;
  gap: 2px;
  padding: var(--space-3) var(--space-5) 0;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
}

.gc-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  background: transparent;
}
.gc-tab:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
}
.gc-tab.active {
  color: var(--color-teal);
  background: var(--bg-surface);
  border-color: var(--border-default);
}

.gc-tab--emergency {
  color: var(--color-red) !important;
  border-color: var(--color-red-border) !important;
}
.gc-tab--emergency.active {
  background: var(--color-red-dim) !important;
}

/* ── LOGIN SCREEN ─────────────────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  transition: background var(--transition-slow);
}

#login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, var(--color-teal-glow) 0%, transparent 70%);
  pointer-events: none;
}

/* ── GRID UTILITIES ───────────────────────────────────────────────────────── */
.gc-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.gc-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
.gc-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.gc-grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }

@media (max-width: 992px) {
  .gc-grid-3 { grid-template-columns: 1fr 1fr; }
  .gc-grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .gc-grid-2 { grid-template-columns: 1fr; }
  .gc-grid-3 { grid-template-columns: 1fr; }
  .gc-grid-4 { grid-template-columns: 1fr 1fr; }
  .gc-content { padding: var(--space-4); }
  .gc-sidebar { display: none; }
}
@media (max-width: 480px) {
  .gc-grid-4 { grid-template-columns: 1fr; }
}

/* ── FLEX UTILITIES ───────────────────────────────────────────────────────── */
.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.gap-1          { gap: var(--space-1); }
.gap-2          { gap: var(--space-2); }
.gap-3          { gap: var(--space-3); }
.gap-4          { gap: var(--space-4); }
.flex-1         { flex: 1; }
.ml-auto        { margin-left: auto; }
.flex-wrap      { flex-wrap: wrap; }

/* ── SPACING UTILITIES ────────────────────────────────────────────────────── */
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

/* ── TEXT UTILITIES ───────────────────────────────────────────────────────── */
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-base    { font-size: var(--text-base); }
.text-lg      { font-size: var(--text-lg); }
.text-xl      { font-size: var(--text-xl); }
.text-mono    { font-family: var(--font-mono); }
.text-muted   { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-primary  { color: var(--text-primary); }
.text-teal    { color: var(--color-teal); }
.text-amber   { color: var(--color-amber); }
.text-red     { color: var(--color-red); }
.text-green   { color: var(--color-green); }
.fw-medium    { font-weight: var(--weight-medium); }
.fw-semi      { font-weight: var(--weight-semi); }
.fw-bold      { font-weight: var(--weight-bold); }
.text-upper   { text-transform: uppercase; letter-spacing: var(--tracking-wider); }
.text-center  { text-align: center; }
.text-nowrap  { white-space: nowrap; }

/* ── SECTION HEADER ───────────────────────────────────────────────────────── */
.gc-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.gc-section-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}
.gc-section-divider {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.gc-section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

/* ── EMPTY STATE ──────────────────────────────────────────────────────────── */
.gc-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}
.gc-empty__icon { font-size: 36px; margin-bottom: var(--space-3); opacity: 0.4; }
.gc-empty__text { font-size: var(--text-sm); }

/* ── OVERLAY / MODAL BACKDROP ─────────────────────────────────────────────── */
.gc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.gc-overlay.active { display: flex; }

/* ── TOAST ────────────────────────────────────────────────────────────────── */
#gc-toast {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 9999;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 340px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-base);
}
#gc-toast.show    { transform: translateY(0); opacity: 1; }
#gc-toast.success { border-color: var(--color-green-border); }
#gc-toast.error   { border-color: var(--color-red-border); }
#gc-toast.warning { border-color: var(--color-amber-border); }

/* ── LOADING SPINNER ──────────────────────────────────────────────────────── */
.gc-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--color-teal);
  border-radius: 50%;
  animation: gc-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes gc-spin { to { transform: rotate(360deg); } }

/* ── THEME TRANSITION ─────────────────────────────────────────────────────── */
*, *::before, *::after {
  transition-property: background-color, border-color, color;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}
/* Override for elements that shouldn't transition color */
.gc-spinner, .gc-pulse, img { transition: none !important; }
