/* ================================================================
   MAPALUS — Custom Design System
   Modern Government Application UI
   ================================================================ */

/* ── Google Fonts fallback (system fonts) ── */
:root {
  --font:       'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* Brand */
  --primary:    #1d4ed8;
  --primary-dk: #1e3a8a;
  --primary-lt: #dbeafe;
  --accent:     #dc2626;

  /* Sidebar */
  --sb-bg:      #0f172a;
  --sb-text:    #94a3b8;
  --sb-hover:   #1e293b;
  --sb-active:  #1d4ed8;
  --sb-w:       240px;

  /* Content */
  --bg:         #f1f5f9;
  --card:       #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;

  /* Status colors */
  --s-hadir:    #16a34a;
  --s-keluar:   #d97706;
  --s-pulang:   #475569;
  --s-absen:    #dc2626;
  --s-rapat:    #0891b2;
  --s-zoom:     #7c3aed;

  --radius:     12px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:  0 4px 6px rgba(0,0,0,.07), 0 10px 40px rgba(0,0,0,.1);
  --topbar-h:   60px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0; padding: 0;
  font-size: 14px;
  line-height: 1.6;
}

/* ================================================================
   LAYOUT — Sidebar + Main
   ================================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sb-w);
  height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1e293b;
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px; color: #fff;
}
.sidebar-brand-text { color: #f1f5f9; font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.sidebar-brand-sub  { color: var(--sb-text); font-size: 9px; line-height: 1.2; margin-top: 1px; }

.sidebar-section {
  padding: 16px 12px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #475569;
}

.sidebar-nav { padding: 0 8px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  position: relative;
}
.sidebar-nav a:hover { background: var(--sb-hover); color: #e2e8f0; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a .nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }
.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid #1e293b;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.sidebar-user:hover { background: var(--sb-hover); }
.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-name  { color: #e2e8f0; font-size: 13px; font-weight: 600; }
.sidebar-user-role  { color: var(--sb-text); font-size: 11px; }

/* ── Overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sb-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
}
.topbar-toggle:hover { background: var(--bg); }
.topbar-title { font-weight: 700; font-size: 15px; color: var(--text); }
.topbar-clock {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
}
.topbar-clock .time { font-weight: 700; color: var(--text); font-size: 14px; }

/* ── Page Content ── */
.page-content { padding: 24px; flex: 1; }

/* ── Responsive ── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .page-content { padding: 16px; }
}

/* ================================================================
   COMPONENTS
   ================================================================ */

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow);
}
.card-header {
  background: var(--card) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 16px 20px !important;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.card-body { padding: 20px !important; }

/* ── Stat Card ── */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 500; }

/* ── Status Badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.sb-hadir   { background: #dcfce7; color: #15803d; }
.sb-absen   { background: #f1f5f9; color: #64748b; }
.sb-keluar  { background: #fef3c7; color: #92400e; }
.sb-pulang  { background: #f1f5f9; color: #475569; }
.sb-rapat   { background: #e0f2fe; color: #075985; }
.sb-zoom    { background: #ede9fe; color: #5b21b6; }
.sb-dinas   { background: #fef3c7; color: #92400e; }

/* ── Avatar ── */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

/* ── Staff Grid Card ── */
.staff-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  transition: box-shadow .2s;
}
.staff-card:hover { box-shadow: var(--shadow-lg); }
.staff-card .staff-name { font-weight: 600; font-size: 13px; }
.staff-card .staff-role { font-size: 11px; color: var(--muted); }

/* ── Tables ── */
.table { font-size: 13px; }
.table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border) !important;
  padding: 10px 12px !important;
  white-space: nowrap;
}
.table td { padding: 12px !important; vertical-align: middle; border-color: var(--border) !important; }
.table-hover tbody tr:hover { background: #f8fafc !important; }

/* ── Forms ── */
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
  background: var(--card);
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
  outline: none;
}
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-text  { font-size: 11.5px; color: var(--muted); }

/* ── Buttons ── */
.btn { border-radius: 8px !important; font-size: 13.5px; font-weight: 600; padding: 8px 16px; }
.btn-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.btn-primary:hover { background: var(--primary-dk) !important; border-color: var(--primary-dk) !important; }
.btn-danger  { background: var(--accent) !important; border-color: var(--accent) !important; }
.btn-lg { padding: 12px 24px !important; font-size: 15px !important; }
.btn-sm { padding: 5px 12px !important; font-size: 12px !important; }

/* ── Alerts ── */
.alert { border-radius: 10px !important; border: none !important; font-size: 13.5px; }
.alert-success { background: #dcfce7 !important; color: #15803d !important; }
.alert-danger  { background: #fee2e2 !important; color: #991b1b !important; }
.alert-warning { background: #fef3c7 !important; color: #92400e !important; }
.alert-info    { background: #e0f2fe !important; color: #075985 !important; }

/* ── Toast ── */
#toastContainer {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.mapalus-toast {
  min-width: 280px;
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease;
  cursor: pointer;
}
@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.mapalus-toast.success { background: #16a34a; }
.mapalus-toast.danger  { background: #dc2626; }
.mapalus-toast.warning { background: #d97706; }
.mapalus-toast.info    { background: #0369a1; }

/* ── Page Headers ── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 20px; font-weight: 800; color: var(--text); margin: 0; }
.page-header p  { font-size: 13px; color: var(--muted); margin: 3px 0 0; }

/* ── Breadcrumb ── */
.breadcrumb { background: none !important; padding: 0 !important; margin: 0; font-size: 12px; }
.breadcrumb-item { color: var(--muted); }
.breadcrumb-item.active { color: var(--text); font-weight: 600; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--border); }

/* ── Modals ── */
.modal-content { border-radius: var(--radius) !important; border: none !important; box-shadow: var(--shadow-lg); }
.modal-header  { border-bottom: 1px solid var(--border) !important; padding: 16px 20px !important; }
.modal-footer  { border-top:  1px solid var(--border) !important; padding: 12px 20px !important; }
.modal-body    { padding: 20px !important; }
.modal-title   { font-size: 15px; font-weight: 700; }

/* ── Checkin specific ── */
.location-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.location-card .coord-val { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.distance-bar { height: 8px; border-radius: 4px; background: #1e293b; overflow: hidden; margin: 8px 0; }
.distance-fill { height: 100%; border-radius: 4px; transition: width .5s ease, background .5s ease; }

/* ── Status display (big) ── */
.status-display {
  text-align: center;
  padding: 32px 20px;
}
.status-display .status-icon { font-size: 56px; margin-bottom: 16px; }
.status-display .status-text { font-size: 22px; font-weight: 800; }
.status-display .status-time { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── Public Display (TV Mode) ── */
body.tv-mode { background: #0a1628; color: #e2e8f0; }
.tv-topbar { background: linear-gradient(135deg, #1e3a8a, #1d4ed8); padding: 16px 28px; }
.tv-clock  { font-variant-numeric: tabular-nums; }
.tv-staff-card {
  background: #1a2540;
  border: 1px solid #2a3a5c;
  border-radius: 10px;
  padding: 14px;
  transition: transform .2s;
}
.tv-staff-card:hover { transform: translateY(-2px); }

/* ── Login page ── */
body.login-bg {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1d4ed8 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-wrap { width: 100%; display: flex; justify-content: center; align-items: center; }
.login-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.97);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-brand h1 {
  font-size: 32px; font-weight: 900; letter-spacing: 4px;
  color: #0f172a; margin: 12px 0 4px;
}
.login-brand p { font-size: 13px; color: #64748b; margin: 0; }
.login-logo {
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 12px;
}
.login-field { margin-bottom: 20px; }
.login-field label {
  display: block; font-size: 13px; font-weight: 700;
  margin-bottom: 6px; color: #374151;
}
.login-field .form-control {
  border-radius: 10px; border: 1.5px solid #e2e8f0;
  padding: 12px 14px; font-size: 14px;
  transition: border .15s;
}
.login-field .form-control:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
.btn-login {
  width: 100%; padding: 14px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700;
  cursor: pointer; transition: background .15s;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
}
.btn-login:hover { background: var(--primary-dk); }
.login-footer { text-align: center; margin-top: 28px; padding-top: 20px; border-top: 1px solid #f1f5f9; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
}

/* ── Misc ── */
code { background: #f1f5f9; color: #0f172a; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dk); }
hr { border-color: var(--border); }
.text-muted { color: var(--muted) !important; }
.badge { font-size: 11px !important; }

/* Fix Bootstrap table inside card */
.card .table { margin-bottom: 0; }
.card .table:first-child td:first-child,
.card .table:first-child th:first-child { padding-left: 20px !important; }

/* ================================================================
   ADDITIONAL UX COMPONENTS (redesign 2026)
   ================================================================ */

/* ── Smooth page entry ── */
.page-content > * { animation: fadeUp .25s ease both; }
@keyframes fadeUp {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ── Focus ring improvement ── */
:focus-visible {
  outline: 3px solid rgba(29,78,216,.35);
  outline-offset: 2px;
}

/* ── Better scrollbar ── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background:#cbd5e1; border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:#94a3b8; }

/* ── Sidebar active indicator line ── */
.sidebar-nav a.active::before {
  content:'';
  position:absolute; left:-8px; top:50%;
  transform:translateY(-50%);
  width:3px; height:20px;
  background:#fff;
  border-radius:2px;
}

/* ── Card hover lift ── */
.card { transition: box-shadow .2s; }

/* ── Empty state ── */
.empty-state {
  text-align:center;
  padding:48px 20px;
  color:var(--muted);
}
.empty-state-icon {
  font-size:48px;
  margin-bottom:16px;
  opacity:.4;
}
.empty-state-title { font-size:15px; font-weight:700; margin-bottom:6px; }
.empty-state-sub   { font-size:13px; }

/* ── Responsive improvements ── */
@media (max-width:576px) {
  .stat-card { padding:14px; gap:12px; }
  .stat-value { font-size:22px; }
  .btn-lg { font-size:14px !important; padding:12px 18px !important; }
  .card-body { padding:16px !important; }
  .card-header { padding:12px 16px !important; }
  .act-type-grid { grid-template-columns:1fr; }
}

/* ── Print improvements ── */
@media print {
  .db-banner, .ci-hero, .ci-gps-bar, .leave-steps { display:none !important; }
}
