/* ============================================================
   ABSENSI ONLINE — Modern Design System v2.0
   PHP 8+ compatible | Mobile-first | No external CSS dependency
   ============================================================ */

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
  --color-primary: #4f46e5;
  --color-primary-light: #6366f1;
  --color-primary-dark: #3730a3;
  --color-primary-rgb: 79, 70, 229;

  --color-accent: #06b6d4;
  --color-accent-light: #22d3ee;
  --color-accent-dark: #0891b2;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #06b6d4;

  --color-white: #ffffff;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;

  --bg-body: #f0f2f5;
  --bg-card: #ffffff;
  --bg-surface: #f8fafc;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-on-primary: #ffffff;

  --border-color: #e5e7eb;
  --border-radius-sm: 8px;
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --border-radius-xl: 24px;
  --border-radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(var(--color-primary-rgb), 0.15);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  
  --header-height: 56px;
  --navbar-height: 64px;
  --max-width: 480px;
  --sidebar-width: 280px;
}

/* ---- Reset ---- */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-dark); }
img { max-width: 100%; height: auto; }

/* ---- App Shell ---- */
#appCapsule {
  padding-top: calc(var(--header-height) + 16px);
  padding-bottom: calc(var(--navbar-height) + 24px);
  min-height: 100vh;
}

/* ---- Header ---- */
.appHeader {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--header-height);
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.appHeader .left {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-on-primary); font-weight: 600; font-size: 0.875rem;
  flex: 1; overflow: hidden;
}
.appHeader .left img {
  width: 32px; height: 32px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
}
.appHeader .right { display: flex; align-items: center; }
.headerButton {
  cursor: pointer;
}
.headerButton img {
  width: 34px; height: 34px; border-radius: var(--border-radius-full);
  object-fit: cover; border: 2px solid rgba(255,255,255,0.3);
}
.headerButton img:hover { border-color: rgba(255,255,255,0.6); }

/* Dropdown */
.dropdown-menu {
  position: absolute; top: 100%; right: 0; margin-top: 8px;
  min-width: 180px;
  background: var(--bg-card); border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
  z-index: 1050; display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 0.875rem;
  color: var(--text-primary); cursor: pointer;
  transition: background 150ms; border: none; background: none;
}
.dropdown-item:hover { background: var(--color-gray-100); color: var(--color-primary); }

/* ---- Bottom Nav ---- */
.navigation {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
  height: var(--navbar-height);
  background: var(--bg-card); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  border-top: 1px solid var(--border-color);
}
.navigation ul {
  display: flex; width: 100%; max-width: var(--max-width);
  list-style: none; justify-content: space-around; padding: 0;
}
.navigation ul li {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; min-width: 56px;
}
.navigation ul li a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-muted); font-size: 0.65rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.navigation ul li a .icon { font-size: 1.4rem; }
.navigation ul li.active a { color: var(--color-primary); }

/* ---- Card ---- */
.card {
  background: var(--bg-card); border-radius: var(--border-radius);
  box-shadow: var(--shadow); border: 1px solid var(--border-color);
  overflow: hidden; transition: box-shadow 250ms;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: 16px; }

/* ---- Wallet Card ---- */
.wallet-card {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  border-radius: var(--border-radius-lg); padding: 20px 16px;
  color: var(--text-on-primary);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  overflow: hidden; position: relative;
}
.wallet-card .balance {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.wallet-card .balance .left .title {
  font-size: 0.875rem; opacity: 0.85; display: block; margin-bottom: 4px;
}
.wallet-card .balance .left .total {
  font-size: 1.5rem; font-weight: 700; margin: 0;
}
.wallet-card .wallet-footer {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.2);
}
.wallet-card .wallet-footer .item { text-align: center; }
.wallet-card .wallet-footer .item a {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text-on-primary); transition: transform 150ms;
}
.wallet-card .wallet-footer .item a:hover { transform: translateY(-2px); }
.wallet-card .wallet-footer .item .icon-wrapper {
  width: 44px; height: 44px; border-radius: var(--border-radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; background: rgba(255,255,255,0.15);
}
.wallet-card .wallet-footer .item strong {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
}

/* ---- Stat Card ---- */
.stat-card {
  background: var(--bg-card); border-radius: var(--border-radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.stat-card .stat-label {
  font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase;
}
.stat-card.success { background: var(--color-success); color: var(--text-on-primary); border: none; }
.stat-card.warning { background: var(--color-warning); color: #000; border: none; }
.stat-card.danger { background: var(--color-danger); color: var(--text-on-primary); border: none; }
.stat-card.info { background: var(--color-info); color: var(--text-on-primary); border: none; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label, .label {
  display: block; font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-control {
  display: block; width: 100%; padding: 12px 14px;
  font-size: 1rem; font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  transition: all 150ms; outline: none;
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--color-gray-100); opacity: 0.7; }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}
.input-wrapper { position: relative; }
.input-group { display: flex; align-items: stretch; }
.input-group .form-control {
  border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
  border-right: none;
}
.input-group-addon {
  display: flex; align-items: center; padding: 0 12px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  color: var(--text-muted); font-size: 1.25rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; font-size: 0.875rem; font-weight: 600;
  font-family: var(--font-sans);
  border: none; border-radius: var(--border-radius-sm);
  cursor: pointer; transition: all 150ms; line-height: 1.5;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 1rem; border-radius: var(--border-radius); }
.btn-sm { padding: 8px 12px; font-size: 0.75rem; }
.btn-primary { background: var(--color-primary); color: var(--text-on-primary); }
.btn-primary:hover { background: var(--color-primary-light); box-shadow: var(--shadow-md); }
.btn-success { background: var(--color-success); color: var(--text-on-primary); }
.btn-danger { background: var(--color-danger); color: var(--text-on-primary); }
.btn-warning { background: var(--color-warning); color: #000; }
.btn-info { background: var(--color-info); color: var(--text-on-primary); }

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; font-size: 0.7rem; font-weight: 600;
  border-radius: var(--border-radius-full);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-success { background: var(--color-success); color: var(--text-on-primary); }
.badge-warning { background: var(--color-warning); color: #000; }
.badge-danger { background: var(--color-danger); color: var(--text-on-primary); }
.badge-info { background: var(--color-info); color: var(--text-on-primary); }
.badge-primary { background: var(--color-primary); color: var(--text-on-primary); }

/* ---- Table ---- */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table thead th {
  padding: 12px; text-align: left; font-weight: 600; font-size: 0.75rem;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--bg-surface); border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
table tbody td, table tbody th {
  padding: 12px; border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}
table tbody tr:last-child td, table tbody tr:last-child th { border-bottom: none; }
table tbody tr:hover { background: var(--color-gray-50); }

/* ---- Alert ---- */
.alert {
  padding: 12px 16px; border-radius: var(--border-radius-sm);
  font-size: 0.875rem; display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ---- Modal ---- */
.modal {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000; background: var(--bg-overlay); align-items: flex-end;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-dialog {
  width: 100%; max-width: var(--max-width); max-height: 90vh;
  background: var(--bg-card);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  box-shadow: var(--shadow-xl); overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border-color);
}
.modal-title { font-size: 1.125rem; font-weight: 700; margin: 0; }
.modal-header .close {
  font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
  background: none; border: none; line-height: 1;
}
.modal-body { padding: 16px; }

/* ---- Sidebar Panel ---- */
.panelbox {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000; background: var(--bg-overlay);
}
.panelbox.show { display: block; }
.profileBox {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: var(--text-on-primary);
}
.profileBox .image-wrapper img {
  width: 48px; height: 48px; border-radius: var(--border-radius-full);
  object-fit: cover; border: 2px solid rgba(255,255,255,0.4);
}
.profileBox .in strong { display: block; font-size: 0.875rem; }
.profileBox .in .text-muted { font-size: 0.75rem; opacity: 0.75; }
.profileBox .sidebar-close {
  margin-left: auto; color: var(--text-on-primary);
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
}
.listview-title {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 12px 16px 8px;
}
.listview { list-style: none; padding: 0; }
.listview li a.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; color: var(--text-primary);
  font-size: 0.875rem; font-weight: 500;
}
.listview li a.item:hover { background: var(--color-gray-100); }
.listview li a.item .icon-box {
  width: 36px; height: 36px; border-radius: var(--border-radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--text-on-primary); flex-shrink: 0;
}
.icon-box.bg-success { background: var(--color-success); }

/* ---- Avatar ---- */
.avatar-section { position: relative; display: inline-block; }
.avatar-section img {
  width: 100px; height: 100px; border-radius: var(--border-radius-full);
  object-fit: cover; border: 3px solid var(--bg-card); box-shadow: var(--shadow-md);
}
.avatar-section .button {
  position: absolute; bottom: 0; right: 0;
  width: 32px; height: 32px; border-radius: var(--border-radius-full);
  background: var(--color-primary); color: var(--text-on-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; border: 2px solid var(--bg-card);
  cursor: pointer;
}
.avatar-section input[type="file"] {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}

/* ---- ID Card ---- */
.id-card {
  width: 300px; max-width: 100%; margin: auto;
  border-radius: var(--border-radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.id-card .body-id-card {
  padding: 24px; display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(180deg, var(--color-primary), var(--color-primary-light) 60%, var(--color-gray-100));
  color: var(--text-on-primary);
}
.id-card .body-id-card .avatar { margin-bottom: 12px; }
.id-card .body-id-card .avatar img {
  width: 80px; height: 80px; border-radius: var(--border-radius-full);
  object-fit: cover; border: 3px solid rgba(255,255,255,0.5);
}
.id-card .body-id-card h3 { font-size: 1.125rem; margin-bottom: 4px; }
.id-card .body-id-card p { font-size: 0.875rem; text-transform: uppercase; opacity: 0.85; }
.id-card .body-id-card .barcode {
  background: var(--bg-card); padding: 8px; border-radius: var(--border-radius-sm);
  margin-top: 16px; box-shadow: var(--shadow-sm);
}
.id-card .body-id-card .barcode img { width: 140px; height: 140px; }

/* ---- Webcam ---- */
.webcam-capture, .webcam-capture video {
  width: 100% !important; max-width: 480px;
  border-radius: var(--border-radius); box-shadow: var(--shadow-md);
  background: var(--color-gray-900);
}

/* ---- Loading Spinner ---- */
.loading {
  display: none; position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%); z-index: 9999;
}
.spinner-border {
  width: 40px; height: 40px; border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-primary); border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loader {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-body); display: flex; align-items: center;
  justify-content: center; z-index: 9999;
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-white { color: var(--text-on-primary); }
.text-muted { color: var(--text-muted); }
.d-none { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 32px; }
.mr-1 { margin-right: 4px; }
.p-2 { padding: 8px; }
.pt-1 { padding-top: 4px; }
.pb-1 { padding-bottom: 4px; }
.w40 { width: 40px; height: 40px; }
.w100 { width: 100px; height: 100px; }
.rounded { border-radius: var(--border-radius); }
.rounded-circle { border-radius: var(--border-radius-full); }
.imaged { object-fit: cover; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.col { flex: 1; padding: 0 8px; min-width: 0; }
.col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; padding: 0 8px; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; padding: 0 8px; }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; padding: 0 8px; }
hr { border: none; border-top: 1px solid var(--border-color); margin: 16px 0; }
.float-right { float: right; }

@media (max-width: 576px) {
  .wallet-card .wallet-footer { grid-template-columns: repeat(2, 1fr); }
  .col-sm-4, .col-md-3, .col-md-4 { flex: 0 0 100%; max-width: 100%; margin-bottom: 8px; }
}
