/* ======================================= */
/* TEMA WARNA BARU - PROFESIONAL MERAH */
/* ======================================= */
:root {
  --primary-color: #C62828;   /* Merah Tua (untuk header, tombol utama) */
  --primary-hover: #B71C1C;   /* Merah Sangat Tua (untuk hover) */
  --danger-color: #D32F2F;    /* Merah Sedikit Lebih Terang (untuk logout) */
  --dark-text: #212121;     /* Hitam Pekat (untuk teks) */
  --light-text: #FFFFFF;    /* Putih (untuk teks di atas warna gelap) */
  --neutral-bg: #f4f4f4;     /* Abu-abu Sangat Muda (untuk background halaman) */
  --card-bg: #FFFFFF;       /* Putih Bersih (untuk background card) */
  --border-color: #e0e0e0;   /* Abu-abu Muda (untuk border) */
}

/* ========================== */
/* Gaya Dasar & Reset         */
/* ========================== */
body, html {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--neutral-bg);
  color: var(--dark-text);
  height: 100%;
  box-sizing: border-box; /* 1. Dasar untuk box-sizing */
}

/* 2. Terapkan ke semua elemen */
*, *:before, *:after {
  box-sizing: inherit;
}

/* ========================== */
/* Layout & Container         */
/* ========================== */
.container {
  width: 100%;
  max-width: 100%;
  padding: 15px; /* Padding ini sekarang aman digunakan */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card {
  width: 100%;
  max-width: 500px; /* 3. Beri batas lebar maksimum pada card */
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-top: 6px solid var(--primary-color);
}

header {
  width: 100%;
  background: var(--primary-color);
  color: var(--light-text);
  padding: 15px;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* ========================== */
/* Form & Tombol              */
/* ========================== */
h2 {
  margin-top: 0;
  text-align: center;
  font-size: 22px;
  color: var(--primary-color);
}

input {
  width: 100%; /* 4. Ubah menjadi 100%, box-sizing akan menanganinya */
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #f9f9f9;
  color: var(--dark-text);
  font-size: 16px;
}

button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary-color);
  color: var(--light-text);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  transition: background-color 0.2s;
}

button:hover { 
  background: var(--primary-hover); 
}

.error {
  color: var(--danger-color);
  margin-top: 10px;
  display: none;
  font-size: 14px;
}

/* ========================== */
/* Halaman Scanner            */
/* ========================== */
#scannerPage {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.video-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.7);
  border: 3px solid var(--primary-color);
}

video { width: 100%; display: block; background: #000; }

.scan-area {
  position: absolute;
  top: 50%; left: 50%;
  width: 70%; height: 50%;
  border: 2px dashed var(--primary-hover);
  border-radius: 8px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#status { 
  margin: 15px 0; 
  padding: 10px;
  border-radius: 5px;
  font-size: 18px;
  font-weight: bold;
  color: var(--dark-text);
}
#status.success {
  background-color: #E8F5E9;
  color: #2E7D32;
}
#status.error {
  background-color: #FFEBEE;
  color: #C62828;
}

.controls {
  margin: 15px 0;
  width: 100%;
  max-width: 420px;
  display: flex;
  gap: 10px;
}

/* ========================== */
/* Tabel Data                 */
/* ========================== */
.table-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  max-height: 400px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  color: var(--dark-text);
}

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

th { 
  background: #f2f2f2; 
  color: var(--primary-color);
}

tr.completed { background: #E8F5E9; color: #2E7D32; }

/* ========================== */
/* Style Navigasi Baru        */
/* ========================== */
.nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  max-width: 800px;
  margin-bottom: 20px;
}

.nav-button {
  flex: 1;
  min-width: 120px;
  padding: 12px 10px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  color: var(--light-text);
  background-color: var(--primary-color);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.nav-button:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
}

.nav-button.logout {
  background-color: var(--danger-color);
}

.nav-button.logout:hover {
  background-color: var(--primary-hover);
}

.user-info-bar {
  width: 100%;
  max-width: 800px;
  padding: 10px 15px;
  margin-bottom: 10px;
  background-color: #FFEBEE; /* Latar belakang merah muda */
  border: 1px solid var(--danger-color);
  border-radius: 8px;
  text-align: center;
  font-size: 16px;
  color: var(--primary-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- TAMBAHKAN KODE BARU INI --- */
.logout-link {
  display: inline-block;
  padding: 8px 12px;
  background-color: var(--danger-color);
  color: var(--light-text);
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
  font-size: 14px;
  transition: background-color 0.2s;
}

.logout-link:hover {
  background-color: var(--primary-hover);
}

/* ========================== */
/* Footer                     */
/* ========================== */
.site-footer {
  width: 100%;
  text-align: center;
  padding: 20px 0;
  margin-top: 30px;
  border-top: 1px solid var(--border-color);
  color: #777;
  font-size: 14px;
}

/* ======================================= */
/* PERBAIKAN RESPONSIVE UNTUK TABEL        */
/* ======================================= */

/* Membuat container tabel bisa di-scroll ke samping di layar kecil */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Scroll lebih mulus di iOS */
}

/* Sedikit penyesuaian agar tabel tidak terlalu mepet di mobile */
@media (max-width: 480px) {
  .table-wrapper table {
    font-size: 14px; /* Kecilkan sedikit font di dalam tabel */
  }
}

/* Style BARU yang lebih ringkas untuk tombol aksi di dalam tabel */
.btn-action-stop {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: bold;
  color: var(--light-text);
  background-color: var(--danger-color);
  border-radius: 5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px; /* Jarak antara ikon dan teks */
  white-space: nowrap; /* Mencegah teks turun ke bawah */
  transition: background-color 0.2s;
}

.btn-action-stop:hover {
  background-color: var(--primary-hover);
}

/* ======================================= */
/* STYLE UNTUK Himbauan/Notifikasi SCAN    */
/* ======================================= */

.scan-notice {
  width: 100%;
  max-width: 420px;
  padding: 15px;
  margin-bottom: 15px;
  border: 1px solid #0D47A1;
  background-color: #E3F2FD;
  color: #0D47A1;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  font-size: 16px;
}

/* ======================================= */
/* STYLE UNTUK TOMBOL GANTI BAGIAN         */
/* ======================================= */

.nav-button.switch {
  background-color: #ff9800; /* Oranye */
}

.nav-button.switch:hover {
  background-color: #f57c00; /* Oranye tua */
}

/* ======================================= */
/* ANIMASI SCANNER & UI UPDATE (DIPERBAIKI) */
/* ======================================= */

/* 1. Garis Laser (Default Merah / Keluar) */
.scan-line {
  width: 100%;
  height: 2px;
  background: #f44336; /* MERAH (Default) */
  position: absolute;
  top: 0;
  left: 0;
  box-shadow: 0 0 4px 2px rgba(244, 67, 54, 0.5); /* Glow Merah */
  animation: scanMotion 2s infinite linear;
  display: none;
}

@keyframes scanMotion {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* 2. Mode MASUK (HIJAU) - Gunakan !important agar pasti berubah */
.scan-area.mode-masuk {
  border-color: #4CAF50 !important; /* Border Hijau */
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.3) inset;
}

/* Ubah warna garis laser jika parentnya punya class mode-masuk */
.scan-area.mode-masuk .scan-line {
  background: #4CAF50 !important; /* Garis Hijau */
  box-shadow: 0 0 4px 2px rgba(76, 175, 80, 0.5) !important; /* Glow Hijau */
}

/* 3. Mode KELUAR (MERAH) */
.scan-area.mode-keluar {
  border-color: #f44336 !important; /* Border Merah */
  box-shadow: 0 0 20px rgba(244, 67, 54, 0.3) inset;
}

/* Style Tombol */
button.active-mode {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(0,0,0,0.3) inset;
  border: 2px solid #fff;
  opacity: 1 !important;
}
button.inactive-mode {
  opacity: 0.5;
  transform: scale(0.95);
}

/* ========================== */
/* Modal Konfirmasi Scan (Modern & Compact) */
/* ========================== */
.modal-overlay {
  display: none; 
  align-items: center; 
  justify-content: center; 
  position: fixed; 
  z-index: 1000; 
  left: 0; top: 0; 
  width: 100%; height: 100%; 
  background-color: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease-in-out;
}

.modal-content-modern {
  background: white; 
  padding: 16px; 
  border-radius: 12px; 
  width: 90%; 
  max-width: 360px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  transform: translateY(0);
  animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header-modern {
  margin: 0 0 12px 0;
  text-align: center;
  font-size: 17px;
  color: var(--primary-color);
  font-weight: bold;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.qr-code-box {
  background: #f8f9fa;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 12px;
  text-align: center;
  font-size: 13px;
  border: 1px dashed #ccc;
}

.form-group-compact {
  margin-bottom: 10px;
}

.form-group-compact label {
  display: block;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 4px;
  color: #444;
}

.form-control-compact {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fff;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-control-compact:focus {
  border-color: #4CAF50;
  outline: none;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

textarea.form-control-compact {
  resize: vertical;
  min-height: 38px;
}

.pekerja-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pekerja-badge {
  background: #f1f3f5;
  color: #495057;
  font-weight: 800;
  font-size: 15px;
  padding: 0 12px;
  height: 38px; /* Match form-control-compact roughly */
  border: 1px solid #ced4da;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.pekerja-badge .org-text {
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
  color: #868e96;
}

.pekerja-dropdown-compact {
  display: none; 
  position: absolute; 
  left: 0; right: 0; top: 100%; 
  max-height: 160px; 
  overflow-y: auto; 
  background: #fff; 
  border: 1px solid #ddd; 
  border-top: none; 
  border-radius: 0 0 6px 6px; 
  z-index: 100; 
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.pekerja-tags-container {
  display: flex; 
  flex-wrap: wrap; 
  gap: 4px; 
  margin-top: 6px; 
  min-height: 24px;
}

.pekerja-info-text {
  color: #888; 
  display: block; 
  margin-top: 2px; 
  font-size: 11px;
}

.modal-actions-compact {
  display: flex;
  gap: 8px;
  margin-top: 15px;
}

.btn-compact {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: none;
}

.btn-confirm { background-color: #4CAF50; color: white; }
.btn-confirm:hover { background-color: #43A047; }
.btn-confirm:disabled { background-color: #A5D6A7; cursor: not-allowed; }
.btn-cancel { background-color: #e0e0e0; color: #333; }
.btn-cancel:hover { background-color: #bdbdbd; }

/* ========================== */
/* Dashboard Modern Tabs      */
/* ========================== */
.dashboard-header-modern {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
  max-width: 800px;
}

.dashboard-header-modern h2 {
  margin-bottom: 10px;
}

.filter-bagian-container {
  background: white;
  padding: 8px 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-color);
}

.modern-tabs {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 15px;
  width: 100%;
  max-width: 800px;
  background: #e0e0e0;
  padding: 5px;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  padding: 10px 5px;
  border: none;
  background: transparent;
  color: #555;
  font-weight: bold;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-transform: none;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
  background: white;
  color: var(--primary-color);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tab-btn .badge {
  background: var(--primary-color);
  color: white;
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}

.tab-btn.active .badge {
  background: var(--danger-color);
}

.tab-content {
  display: none;
  width: 100%;
  max-width: 800px;
  animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
  display: block;
}

.card-dashboard {
  max-width: 100%;
  border-top: none;
  box-shadow: 0 6px 15px rgba(0,0,0,0.08);
}

/* ========================== */
/* Table Modern               */
/* ========================== */
.table-modern {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-modern thead th {
  background: #f8f9fa;
  color: #444;
  font-weight: 700;
  padding: 12px;
  border-bottom: 2px solid var(--border-color);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-modern tbody td {
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
  font-size: 14px;
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

.table-modern tbody tr:hover td {
  background: #fafafa;
}

.text-muted {
  color: #888;
}

.text-success {
  color: #2E7D32;
}

.text-primary {
  color: #1565C0;
}

.font-weight-bold {
  font-weight: 700;
}

.badge-bagian {
  background: #e3f2fd;
  color: #0d47a1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  border: 1px solid #bbdefb;
}

.empty-row td {
  text-align: center;
  padding: 20px;
  color: #888;
  font-style: italic;
}

/* Adjustments for mobile */
@media (max-width: 600px) {
  .modern-tabs {
    flex-direction: column;
  }
  .tab-btn {
    padding: 12px;
  }
}

/* ========================== */
/* Scanner Buttons Modern     */
/* ========================== */
.btn-scan-main {
  flex: 1;
  padding: 15px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 12px;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  text-transform: uppercase;
}

.btn-scan-masuk {
  background: linear-gradient(135deg, #4CAF50, #2E7D32);
}
.btn-scan-masuk:hover {
  background: linear-gradient(135deg, #43A047, #1B5E20);
  transform: translateY(-2px);
}

.btn-scan-keluar {
  background: linear-gradient(135deg, #f44336, #c62828);
}
.btn-scan-keluar:hover {
  background: linear-gradient(135deg, #e53935, #b71c1c);
  transform: translateY(-2px);
}

/* ========================== */
/* Header & Navigation Modern */
/* ========================== */
.header-modern {
  width: 100%;
  max-width: 800px;
  background: white;
  color: var(--primary-color);
  padding: 12px 20px;
  border-radius: 12px;
  margin-bottom: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-color);
}
.header-modern img { height: 45px; }
.header-modern-title { font-size: 18px; font-weight: 800; }
.header-clock { font-size: 14px; font-weight: 600; color: #666; text-align: right; }

.user-info-modern {
  width: 100%;
  max-width: 800px;
  padding: 10px 15px;
  margin-bottom: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  border: 1px solid var(--border-color);
  color: #333;
}
.user-info-modern b { color: var(--primary-color); }

.nav-bar-modern {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 800px;
  margin-bottom: 25px;
}
.nav-btn-modern {
  flex: 1;
  padding: 12px 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  background: white;
  color: #555;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.nav-btn-modern i { font-size: 18px; color: var(--primary-color); }
.nav-btn-modern:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--primary-color);
  color: var(--primary-color);
}
.nav-btn-modern.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}
.nav-btn-modern.active i { color: white; }

.logout-link-modern:hover {
  background: var(--danger-color) !important;
  color: white !important;
}