/* HRMS design system — construction/industrial theme */
:root {
  color-scheme: light;
  --hrms-primary: #f5a623;      /* safety yellow */
  --hrms-primary-600: #d98a0b;
  --hrms-dark: #1f2a3d;
  --hrms-dark-2: #2a374d;
  --hrms-slate: #5a6b82;
  --hrms-bg: #f2f4f8;
  --hrms-surface: #ffffff;
  --hrms-border: #e2e7ee;
  --hrms-success: #2fa84f;
  --hrms-warn: #e6a817;
  --hrms-danger: #d64545;
  --hrms-info: #2e7cd6;
  --hrms-radius: 10px;
  --hrms-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --hrms-sidebar-w: 248px;
}

body.hrms {
  background: var(--hrms-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .95rem;
  color: #1f2a3d;
  -webkit-font-smoothing: antialiased;
}

/* Card */
.hrms-card {
  background: var(--hrms-surface);
  border: 1px solid var(--hrms-border);
  border-radius: var(--hrms-radius);
  box-shadow: var(--hrms-shadow);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.hrms-card h5, .hrms-card .hrms-card-title {
  margin-bottom: .75rem;
  font-weight: 600;
  color: var(--hrms-dark);
}

/* Stat cards */
.stat-card { background: var(--hrms-surface); border: 1px solid var(--hrms-border); border-radius: var(--hrms-radius); padding: .9rem 1rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--hrms-slate); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--hrms-dark); }
.stat-card .stat-sub { font-size: .78rem; color: var(--hrms-slate); }
.stat-card.stat-warn { border-left: 4px solid var(--hrms-warn); }
.stat-card.stat-danger { border-left: 4px solid var(--hrms-danger); }
.stat-card.stat-success { border-left: 4px solid var(--hrms-success); }

/* Status chips */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .74rem; font-weight: 600;
  padding: .18rem .5rem; border-radius: 999px;
  background: #eef1f5; color: var(--hrms-slate);
  border: 1px solid var(--hrms-border);
}
.chip-success { background: #e7f5ec; color: #1f7a3d; border-color: #c9ecd8; }
.chip-warn    { background: #fdf4e0; color: #8a6116; border-color: #f5dfae; }
.chip-danger  { background: #fbe9e9; color: #a32d2d; border-color: #f5caca; }
.chip-info    { background: #e4f0fd; color: #1f5ea8; border-color: #c8ddf6; }
.chip-muted   { background: #eef1f5; color: var(--hrms-slate); }

/* Sidebar */
.hrms-sidebar {
  width: var(--hrms-sidebar-w); min-height: 100vh;
  background: var(--hrms-dark); color: #cfd8e3;
  position: sticky; top: 0;
}
.hrms-sidebar .brand {
  padding: 1rem 1.25rem; font-weight: 700; font-size: 1.05rem;
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .5rem;
}
.hrms-sidebar .brand .badge {
  background: var(--hrms-primary); color: #1f2a3d; border-radius: 6px;
  padding: 2px 7px; font-size: .7rem; font-weight: 800; letter-spacing: .04em;
}
.hrms-sidebar .nav-section { padding: .75rem 1.25rem .35rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #6f7f96; }
.hrms-sidebar .nav-link {
  color: #b8c3d4; padding: .55rem 1.25rem; display: flex; align-items: center; gap: .7rem;
  border-left: 3px solid transparent; font-size: .9rem;
}
.hrms-sidebar .nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.hrms-sidebar .nav-link.active { background: rgba(245,166,35,.12); color: #fff; border-left-color: var(--hrms-primary); font-weight: 600; }
.hrms-sidebar .nav-link .icon { width: 1.15rem; text-align: center; }
.hrms-sidebar .role-chip {
  margin: 1rem 1.25rem 0; padding: .6rem;
  background: rgba(255,255,255,.06); border-radius: 8px; font-size: .78rem;
}

/* Top bar */
.hrms-topbar {
  background: var(--hrms-surface); border-bottom: 1px solid var(--hrms-border);
  padding: .7rem 1.5rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 50;
}
.hrms-topbar .page-title { font-weight: 700; color: var(--hrms-dark); }
.hrms-topbar .user-chip {
  margin-left: auto; display: flex; align-items: center; gap: .6rem;
  background: var(--hrms-bg); padding: .35rem .75rem; border-radius: 999px; font-size: .85rem;
}
.hrms-topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--hrms-primary); color: #1f2a3d; display: grid; place-items: center;
  font-weight: 700; font-size: .8rem;
}

/* Tables */
.hrms-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.hrms-table th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--hrms-slate); font-weight: 600; padding: .6rem .75rem;
  border-bottom: 2px solid var(--hrms-border); text-align: left;
}
.hrms-table td { padding: .65rem .75rem; border-bottom: 1px solid var(--hrms-border); vertical-align: middle; }
.hrms-table tr:hover td { background: #f9fafd; }
.hrms-table .thumb {
  width: 38px; height: 38px; border-radius: 6px; object-fit: cover;
  background: #eef1f5; display: inline-block;
}

/* Buttons */
.btn-hrms {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--hrms-primary); color: #1f2a3d;
  border: 1px solid var(--hrms-primary-600);
  padding: .5rem 1rem; border-radius: 8px; font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: .12s;
}
.btn-hrms:hover { background: var(--hrms-primary-600); color: #fff; }
.btn-hrms.btn-ghost { background: transparent; color: var(--hrms-dark); border-color: var(--hrms-border); }
.btn-hrms.btn-ghost:hover { background: var(--hrms-bg); }
.btn-hrms.btn-outline { background: #fff; color: var(--hrms-dark); }
.btn-hrms:disabled, .btn-hrms[disabled] { opacity: .5; cursor: not-allowed; }

/* Forms */
.hrms-input, .hrms-select, .hrms-textarea {
  border: 1px solid var(--hrms-border); border-radius: 8px;
  padding: .55rem .7rem; font-size: .9rem; width: 100%; background: #fff;
}
.hrms-input:focus, .hrms-select:focus, .hrms-textarea:focus {
  outline: none; border-color: var(--hrms-primary); box-shadow: 0 0 0 3px rgba(245,166,35,.15);
}
.hrms-form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem 1rem; }
@media (max-width: 600px) { .hrms-form-grid { grid-template-columns: 1fr; } }
.hrms-field { display: flex; flex-direction: column; gap: .3rem; }
.hrms-field label { font-size: .78rem; font-weight: 600; color: var(--hrms-slate); }
.hrms-field .hint { font-size: .74rem; color: var(--hrms-slate); }

/* Selfie capture */
.selfie-box {
  position: relative; aspect-ratio: 1 / 1; max-width: 320px; margin: 0 auto;
  background: #000; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
}
.selfie-box video, .selfie-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.selfie-box .capture-ui { position: absolute; inset: 0; display: block; background: transparent; pointer-events: none; }
.selfie-box .live-badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(214,69,69,.95); color: #fff; font-weight: 700; font-size: .72rem;
  padding: 2px 8px; border-radius: 999px; display: flex; gap: .35rem; align-items: center;
}
.selfie-box .live-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.capture-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: #fff; border: 4px solid var(--hrms-primary);
  cursor: pointer; display: grid; place-items: center;
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  pointer-events: auto; box-shadow: 0 2px 12px rgba(0,0,0,.28);
}
.selfie-box .live-badge { z-index: 2; }

/* Live tracking indicator */
.track-indicator {
  position: fixed; right: 12px; bottom: 12px; z-index: 999;
  background: #101828; color: #fff; font-size: .78rem;
  padding: .5rem .85rem; border-radius: 999px;
  display: flex; gap: .5rem; align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.track-indicator .dot { width: 10px; height: 10px; border-radius: 50%; }
.track-indicator.active .dot { background: #2fa84f; }
.track-indicator.stale .dot { background: #e6a817; }
.track-indicator.interrupted .dot { background: #d64545; }

/* Layout grid: sidebar + main content */
.hrms-main { padding-top: 0; }
@media (min-width: 769px) {
  body.hrms.has-sidebar { display: grid; grid-template-columns: var(--hrms-sidebar-w) minmax(0, 1fr); }
  .hrms-main { min-width: 0; width: 100%; }
  .hrms-sidebar { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
}
@media (max-width: 768px) {
  body.hrms { display: block; }
  .hrms-sidebar {
    position: fixed; top: 0; left: -260px; width: 260px; z-index: 200;
    transition: left .25s ease; max-height: 100vh; overflow-y: auto;
  }
  .hrms-sidebar.show { left: 0; }
  .hrms-main { padding-top: 0; }
}


/* Staff/employee pages have no sidebar: never reserve the admin sidebar column. */
@media (min-width: 769px) {
  body.hrms.no-sidebar { display: block !important; width: 100%; }
  body.hrms.no-sidebar > .hrms-main { width: 100%; min-width: 0; margin-left: 0; grid-column: auto; }
}

/* Mobile bottom nav */
.hrms-bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--hrms-surface); border-top: 1px solid var(--hrms-border);
  z-index: 100;
}
.hrms-bottom-nav a {
  flex: 1; text-align: center; padding: .7rem .4rem; font-size: .72rem;
  color: var(--hrms-slate); text-decoration: none; display: flex; flex-direction: column; gap: .2rem;
}
.hrms-bottom-nav a.active { color: var(--hrms-dark); font-weight: 700; }
.hrms-bottom-nav a .icon { font-size: 1.2rem; }
@media (max-width: 768px) {
  .hrms-bottom-nav { display: flex; }
  .hrms-sidebar { display: none; }
  body.hrms { padding-bottom: 64px; }
  .hrms-topbar { padding: .6rem 1rem; }
}

/* Flash messages */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .75rem; font-size: .9rem; border: 1px solid; }
.flash-success { background: #e7f5ec; color: #1f7a3d; border-color: #c9ecd8; }
.flash-warn    { background: #fdf4e0; color: #8a6116; border-color: #f5dfae; }
.flash-danger  { background: #fbe9e9; color: #a32d2d; border-color: #f5caca; }
.flash-info    { background: #e4f0fd; color: #1f5ea8; border-color: #c8ddf6; }

/* Loading */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--hrms-border); border-top-color: var(--hrms-primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Map */
.hrms-map { height: 420px; border-radius: var(--hrms-radius); overflow: hidden; background: #dde5ef; }
.map-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .5rem; font-size: .8rem; color: var(--hrms-slate); }
.map-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }

/* Utility */
.muted { color: var(--hrms-slate); }
.text-sm { font-size: .82rem; }
.fs { font-variant-numeric: tabular-nums; }
.divider { border: 0; border-top: 1px solid var(--hrms-border); margin: 1rem 0; }


/* Attendance map fallback and Google Maps embed */
.hrms-map { min-height: 320px; position: relative; }
.hrms-map iframe { display: block; width: 100%; height: 100%; min-height: 320px; border: 0; border-radius: inherit; }
.trail-empty { min-height: 320px; padding: 2rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; text-align: center; color: #52627a; background: #f3f6fa; border: 1px dashed #cbd5e1; border-radius: 12px; }
.trail-empty strong { color: #1e293b; font-size: 1rem; }
.trail-empty span { max-width: 34rem; font-size: .9rem; }
#trailActions .btn-hrms { text-decoration: none; }
