/* ============================================================
   HadiRin Absensi - Global Styles
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:      #10b981;
  --primary-dark: #059669;
  --primary-light:#d1fae5;
  --secondary:    #1e293b;
  --accent:       #f59e0b;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --success:      #10b981;
  --bg:           #0f172a;
  --bg2:          #1e293b;
  --bg3:          #334155;
  --card:         #1e293b;
  --border:       #334155;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;
  --radius:       12px;
  --radius-lg:    20px;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.3);
  --transition:   .2s ease;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Typography ── */
h1,h2,h3,h4,h5,h6 { font-weight: 700; line-height: 1.3; }
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
p { color: var(--text-muted); }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { border-color: var(--primary); box-shadow: var(--shadow); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .625rem 1.25rem;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--bg3); color: var(--text); }
.btn-secondary:hover:not(:disabled){ background: #475569; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }
.btn-warning   { background: var(--warning); color: #1a1a1a; }
.btn-warning:hover:not(:disabled)  { background: #d97706; }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled)    { background: var(--bg3); color: var(--text); }
.btn-lg { padding: .875rem 1.75rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: .375rem .875rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-muted); margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .05em; }
.form-control {
  width: 100%; padding: .75rem 1rem;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: inherit; font-size: .95rem;
  transition: var(--transition); outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.form-control::placeholder { color: var(--text-dim); }
.form-control:disabled { opacity: .5; cursor: not-allowed; }
select.form-control option { background: var(--bg2); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge-success { background: rgba(16,185,129,.15); color: #10b981; }
.badge-danger  { background: rgba(239,68,68,.15);  color: #ef4444; }
.badge-warning { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-info    { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge-muted   { background: var(--bg3); color: var(--text-muted); }

/* ── Alerts ── */
.alert { padding: 1rem 1.25rem; border-radius: var(--radius); font-size: .9rem; display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.alert-success { background: rgba(16,185,129,.1);  border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.alert-danger  { background: rgba(239,68,68,.1);   border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,.1);  border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }
.alert-info    { background: rgba(59,130,246,.1);  border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg3); }
thead th { padding: .875rem 1rem; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); text-align: left; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: .875rem 1rem; font-size: .9rem; vertical-align: middle; }

/* ── Stat Cards ── */
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon { width: 52px; height: 52px; border-radius: var(--radius); display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; font-weight: 500; }

/* ── Sidebar ── */
.sidebar {
  width: 260px; background: var(--bg2);
  border-right: 1px solid var(--border);
  height: 100vh; position: fixed; left: 0; top: 0;
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 100;
  transition: transform .3s ease;
}
.sidebar-logo { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.sidebar-logo .logo-icon { width: 38px; height: 38px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-radius: 10px; display: grid; place-items: center; font-size: 1.2rem; }
.sidebar-logo .logo-text { font-size: 1.1rem; font-weight: 800; }
.sidebar-logo .logo-text span { color: var(--primary); }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-section { padding: .5rem 1.25rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); margin-top: .5rem; }
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem; margin: .1rem .75rem;
  border-radius: var(--radius); cursor: pointer;
  color: var(--text-muted); font-size: .9rem; font-weight: 500;
  transition: var(--transition); text-decoration: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(16,185,129,.15); color: var(--primary); border-left: 3px solid var(--primary); }
.nav-item .icon { width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; min-width: 20px; text-align: center; }
.sidebar-user { padding: 1rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.sidebar-user img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--bg3); }
.sidebar-user .user-avatar-placeholder { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: grid; place-items: center; font-size: 1rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: .75rem; color: var(--text-muted); }

/* ── Main Content ── */
.main-wrapper { margin-left: 260px; min-height: 100vh; background: var(--bg); }
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(15,23,42,.8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar-title { font-size: 1.1rem; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.page-content { padding: 1.5rem; }

/* ── Mobile Sidebar Toggle ── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 99; }
.btn-menu { display: none; background: transparent; border: none; cursor: pointer; color: var(--text); padding: .25rem; }

/* ── Modals ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.7); z-index: 200;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fadeIn .2s ease; }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem; width: 100%;
  max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow); animation: slideUp .25s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-header h3 { font-size: 1.1rem; }
.btn-close { background: transparent; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; line-height: 1; transition: var(--transition); }
.btn-close:hover { color: var(--danger); }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Camera Modal ── */
.camera-preview { width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; position: relative; }
.camera-preview video, .camera-preview img { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { color: var(--text-dim); font-size: 3rem; }

/* ── Calendar ── */
.calendar { width: 100%; border-collapse: collapse; }
.calendar th { padding: .5rem; font-size: .75rem; font-weight: 700; color: var(--text-muted); text-align: center; text-transform: uppercase; }
.calendar td { padding: .25rem; text-align: center; }
.cal-day {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem; cursor: pointer; margin: auto;
  transition: var(--transition); position: relative;
}
.cal-day:hover { background: var(--bg3); }
.cal-day.hadir     { background: rgba(16,185,129,.25); color: #6ee7b7; }
.cal-day.terlambat { background: rgba(245,158,11,.25);  color: #fcd34d; }
.cal-day.absen     { background: rgba(239,68,68,.25);   color: #fca5a5; }
.cal-day.izin      { background: rgba(59,130,246,.25);  color: #93c5fd; }
.cal-day.today     { border: 2px solid var(--primary); }
.cal-day.other-month { opacity: .3; }
.cal-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.cal-legend-item { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text-muted); }
.cal-legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── GPS Status ── */
.gps-status { display: flex; align-items: center; gap: .75rem; padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.gps-status.dalam  { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.gps-status.luar   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.gps-status.loading{ background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }
.gps-icon { font-size: 1.4rem; }

/* ── Toast Notifications ── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1.25rem; border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 280px; max-width: 360px;
  animation: slideInRight .3s ease;
  font-size: .9rem; font-weight: 500;
}
.toast-success { background: #065f46; border: 1px solid #10b981; color: #d1fae5; }
.toast-error   { background: #7f1d1d; border: 1px solid #ef4444; color: #fee2e2; }
.toast-warning { background: #78350f; border: 1px solid #f59e0b; color: #fef3c7; }
.toast-info    { background: #1e3a5f; border: 1px solid #3b82f6; color: #dbeafe; }
.toast-icon    { font-size: 1.1rem; flex-shrink: 0; }

/* ── Skeleton loader ── */
.skeleton { background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%); background-size: 200%; animation: shimmer 1.4s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }

/* ── Animations ── */
@keyframes fadeIn   { from{opacity:0} to{opacity:1} }
@keyframes slideUp  { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideInRight { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.pulse { animation: pulse 2s infinite; }

/* ── Utility ── */
.hidden   { display: none !important; }
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-sm  { font-size: .85rem; }
.text-xs  { font-size: .75rem; }
.text-lg  { font-size: 1.1rem; }
.text-xl  { font-size: 1.35rem; }
.text-2xl { font-size: 1.75rem; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary  { color: var(--primary) !important; }
.text-danger   { color: var(--danger) !important; }
.text-warning  { color: var(--warning) !important; }
.text-success  { color: var(--success) !important; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .btn-menu { display: block; }
  .main-wrapper { margin-left: 0; }
  .topbar { padding: .875rem 1rem; }
  .page-content { padding: 1rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .modal { padding: 1.25rem; }
  #toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { min-width: unset; }
}
