:root {
  --primary-dark-teal: #164E54; /* Warna utama gelap */
  --primary-teal-light: #2AB3B3; /* Warna teal cerah */
  --accent-orange: #D97A38; /* Warna aksen oranye untuk CTA */
  --neutral-white: #FFFFFF; /* Warna putih bersih */
  --neutral-light-grey: #F8F8F6; /* Background mirip absensi-go.id */
  --neutral-dark-grey: #333333; /* Teks gelap untuk kontras */
  --secondary-grey: #6B7280; /* Teks sekunder */
  --status-green: #16a34a; /* Status Hadir */
  --status-red: #dc2626; /* Status Absen */
  --status-yellow: #d97706; /* Status Izin */
  --status-blue: #2563eb; /* Status Sakit */

  --base-font-size: 16px;
  --border-radius-card: 24px; /* Border radius yang lebih membulat */
  --border-radius-button: 8px; /* Border radius tombol */
  --shadow-card: 0 4px 12px rgba(0,0,0,0.1); /* Shadow halus untuk kartu */
}

body {
  font-family: 'Inter', system-ui, Avenir, Helvetica, Arial, sans-serif;
  background-color: var(--neutral-light-grey);
  color: var(--neutral-dark-grey);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  font-size: var(--base-font-size);
  overflow-x: hidden; /* Hindari scroll horizontal */
}

/* ==== LAYOUT & CONTAINER ==== */
.app-container {
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  padding-top: 80px; /* Tinggi top bar */
  box-sizing: border-box;
}

.screen.active {
  display: block;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background-color: var(--primary-dark-teal);
  color: var(--neutral-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.top-bar .back-btn {
  background: none;
  border: none;
  color: var(--neutral-white);
  font-size: 1.2em;
  cursor: pointer;
  padding: 10px;
}

.school-label {
  font-weight: bold;
  background-color: rgba(255,255,255,0.2);
  padding: 5px 10px;
  border-radius: 5px;
}

.screen-title {
  text-align: center;
  margin-bottom: 30px;
}

.screen-title h2 {
  font-size: 2em;
  color: var(--primary-dark-teal);
  margin-bottom: 5px;
}

.screen-title p {
  color: var(--secondary-grey);
}

/* ==== HOME SCREEN ==== */
#screen-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to right, var(--primary-dark-teal), var(--primary-teal-light));
  color: var(--neutral-white);
  text-align: center;
}

.logo-area {
  margin-bottom: 40px;
}

.logo-icon {
  font-size: 4em;
  margin-bottom: 15px;
}

.logo-area h1 {
  font-size: 2.5em;
  margin-bottom: 5px;
}

.logo-area p {
  font-size: 1.1em;
  opacity: 0.8;
}

.card-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 30px;
  width: 100%;
  max-width: 800px;
}

.school-card {
  background-color: var(--neutral-white);
  padding: 30px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  text-align: center;
  flex: 1;
  min-width: 250px;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.school-card:hover {
  transform: translateY(-5px);
}

.school-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.school-card h2 {
  font-size: 1.8em;
  color: var(--primary-dark-teal);
  margin-bottom: 8px;
}

.school-card p {
  color: var(--secondary-grey);
  margin-bottom: 15px;
}

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.8em;
}

.badge-green { background-color: var(--status-green); color: white; }
.badge-blue { background-color: var(--status-blue); color: white; }

/* ==== ROLE SELECTION ==== */
.role-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.role-card {
  background-color: var(--neutral-white);
  padding: 25px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  min-width: 300px;
  transition: transform 0.3s ease;
  border: 1px solid #eee;
}

.role-card:hover {
  transform: translateX(5px);
}

.role-card .role-icon {
  font-size: 2.5em;
}

.role-card h3 {
  font-size: 1.5em;
  color: var(--primary-dark-teal);
  margin-bottom: 3px;
}

.role-card p {
  color: var(--secondary-grey);
}

.role-card .arrow {
  font-size: 1.8em;
  margin-left: auto;
  color: var(--secondary-grey);
}

/* ==== LOGIN SCREEN ==== */
.login-box {
  background-color: var(--neutral-white);
  padding: 40px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  max-width: 450px;
  margin: 50px auto;
  text-align: center;
  border: 1px solid #eee;
}

.login-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.login-box h2 {
  font-size: 2em;
  color: var(--primary-dark-teal);
  margin-bottom: 10px;
}

.login-box p {
  color: var(--secondary-grey);
  margin-bottom: 25px;
}

.input-group {
  margin-bottom: 20px;
  text-align: left;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--primary-dark-teal);
  font-weight: bold;
}

.input-group input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ccc;
  border-radius: var(--border-radius-button);
  font-size: 1em;
  box-sizing: border-box;
}

.error-msg {
  color: var(--status-red);
  font-weight: bold;
  margin-bottom: 15px;
  padding: 10px;
  background-color: var(--status-red-light, #fee2e2);
  border-radius: var(--border-radius-button);
}

.btn-primary {
  background-color: var(--accent-orange);
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: var(--border-radius-button);
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.btn-primary:hover {
  background-color: #d47030;
}

/* PIN PAD */
.pin-pad {
  margin-top: 30px;
}

.pin-display {
  font-size: 2em;
  color: var(--primary-dark-teal);
  margin-bottom: 20px;
  letter-spacing: 10px; /* Spasi antar dot */
  text-align: center;
  height: 40px;
}

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.pin-grid button {
  background-color: #e5e7eb;
  color: var(--primary-dark-teal);
  border: none;
  padding: 18px;
  border-radius: var(--border-radius-button);
  font-size: 1.5em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.pin-grid button:hover {
  background-color: #d1d5db;
}

.pin-grid button.pin-clear, .pin-grid button.pin-del {
  background-color: #fca5a3; /* Merah muda */
  color: white;
}

.pin-grid button.pin-clear:hover, .pin-grid button.pin-del:hover {
  background-color: #f87171;
}

/* ==== DASHBOARD ADMIN ==== */
.dashboard-header {
  text-align: center;
  margin-bottom: 25px;
}

.dashboard-header h2 {
  font-size: 2em;
  color: var(--primary-dark-teal);
  margin-bottom: 5px;
}

.dashboard-header p {
  color: var(--secondary-grey);
}

.tab-group {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
  gap: 10px;
  flex-wrap: wrap;
}

.tab {
  background-color: #e5e7eb;
  color: var(--secondary-grey);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.tab.active {
  background-color: var(--primary-dark-teal);
  color: white;
  font-weight: bold;
}

.tab-content {
  display: none;
  margin-top: 20px;
}

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

.summary-cards {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.summary-card {
  background-color: var(--neutral-white);
  padding: 20px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  text-align: center;
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.summary-card.green { border-left: 5px solid var(--status-green); }
.summary-card.red { border-left: 5px solid var(--status-red); }
.summary-card.yellow { border-left: 5px solid var(--status-yellow); }
.summary-card.blue { border-left: 5px solid var(--status-blue); }

.sc-num {
  font-size: 2em;
  font-weight: bold;
  color: var(--primary-dark-teal);
  margin-bottom: 5px;
}

.table-wrapper {
  background-color: var(--neutral-white);
  padding: 25px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  overflow-x: auto; /* Agar tabel bisa di-scroll di mobile */
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.data-table thead th {
  background-color: var(--primary-dark-teal);
  color: white;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 0.9em;
}

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

.status-pill {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 15px;
  font-weight: bold;
  font-size: 0.85em;
  text-transform: capitalize;
}

.status-pill.status-hadir { background-color: var(--status-green); color: white; }
.status-pill.status-absen { background-color: var(--status-red); color: white; }
.status-pill.status-izin { background-color: var(--status-yellow); color: white; }
.status-pill.status-sakit { background-color: var(--status-blue); color: white; }
.status-pill.status-belum { background-color: #e5e7eb; color: var(--secondary-grey); }

.chart-container {
  background-color: var(--neutral-white);
  padding: 25px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.chart-container h3 {
  font-size: 1.5em;
  color: var(--primary-dark-teal);
  margin-bottom: 20px;
}

canvas {
  max-width: 100%;
  height: auto;
}

/* ==== DASHBOARD GURU ==== */
.absen-form {
  background-color: var(--neutral-white);
  padding: 30px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  text-align: center;
  margin-bottom: 30px;
}

.absen-form h3 {
  font-size: 1.8em;
  color: var(--primary-dark-teal);
  margin-bottom: 15px;
}

.status-hari {
  color: var(--secondary-grey);
  margin-bottom: 20px;
  font-size: 1.1em;
}

.status-btn-group {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.status-btn {
  padding: 12px 20px;
  border-radius: var(--border-radius-button);
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  color: white;
}

.status-btn.hadir {
  background-color: var(--status-green);
}
.status-btn.hadir:hover { background-color: #149440; }

.status-btn.izin {
  background-color: var(--status-yellow);
}
.status-btn.izin:hover { background-color: #d47f05; }

.status-btn.sakit {
  background-color: var(--status-blue);
}
.status-btn.sakit:hover { background-color: #1f52cc; }

.siswa-absen-item {
  background-color: var(--neutral-white);
  padding: 15px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  border: 1px solid #eee;
}

.siswa-absen-item .nama {
  font-weight: bold;
  color: var(--primary-dark-teal);
  margin-bottom: 3px;
}

.siswa-absen-item .nis {
  font-size: 0.9em;
  color: var(--secondary-grey);
}

.siswa-absen-btns {
  display: flex;
  align-items: center;
}

.siswa-absen-btns button {
  background: none;
  border: none;
  font-size: 1.5em;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  margin-left: 5px;
}

.siswa-absen-btns button:hover {
  background-color: rgba(0,0,0,0.08);
}

.siswa-absen-item .status-pill {
  min-width: 80px; /* Agar status pill sejajar */
}

.filter-row {
  margin-bottom: 20px;
}

.filter-row select {
  padding: 10px 15px;
  border: 1px solid #ccc;
  border-radius: var(--border-radius-button);
  font-size: 1em;
  background-color: var(--neutral-white);
}

/* ==== UTILITIES ==== */
.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .top-bar {
    padding: 0 10px;
  }
  .screen-title h2 {
    font-size: 1.8em;
  }
  .login-box {
    margin: 20px auto;
    padding: 30px;
  }
  .pin-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .tab-group {
    flex-wrap: wrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 10px;
  }
  .tab {
    padding: 8px 15px;
    font-size: 0.9em;
  }
  .summary-cards {
    flex-wrap: wrap;
    justify-content: center;
  }
  .summary-card {
    flex: none;
    width: 150px;
  }
  .data-table th, .data-table td {
    padding: 10px;
    font-size: 0.9em;
  }
  .siswa-absen-item {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .siswa-absen-btns {
    margin-top: 10px;
    width: 100%;
    justify-content: center;
  }
  .siswa-absen-item .status-pill {
    margin-top: 10px;
    width: auto;
  }
}

@media (max-width: 480px) {
  .logo-area h1 { font-size: 2em; }
  .logo-area p { font-size: 1em; }
  .school-card, .role-card {
    min-width: 100%;
  }
  .pin-grid button {
    font-size: 1.2em;
    padding: 15px;
  }
  .pin-display {
    font-size: 1.8em;
    height: 35px;
  }
}
