@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-color: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.15);
  --font-sans: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* Container */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header & Navbar */
header {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--transition);
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  white-space: nowrap; /* Mencegah logo pecah baris */
}

.logo span {
  background: linear-gradient(135deg, var(--primary), var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  white-space: nowrap; /* Mencegah teks menu pecah baris */
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-logout {
  background: var(--danger-bg);
  color: #fca5a5 !important;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Navigation Dropdown Menu styling */
.nav-dropdown-container {
  position: relative;
  display: inline-block;
}

.nav-dropdown-btn {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  height: 38px;
  font-family: inherit;
}

.nav-dropdown-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.nav-dropdown-btn span {
  font-size: 0.6rem;
  transition: transform 0.3s ease;
}

.nav-dropdown-btn.active span {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  width: 200px;
  z-index: 1000;
  overflow: hidden;
}

.nav-dropdown-menu.show {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: left;
}

.nav-dropdown-menu a:last-child {
  border-bottom: none;
}

.nav-dropdown-menu a:hover, .nav-dropdown-menu a.active {
  background: var(--primary);
  color: white;
}

.btn-logout:hover {
  background: var(--danger) !important;
  color: var(--text-primary) !important;
}

/* Lonceng Notifikasi Dropdown */
.notification-bell-container {
  position: relative;
  display: inline-block;
}

.notification-bell-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  position: relative;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-bell-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.notification-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.35rem;
  border-radius: 9999px;
  line-height: 1;
}

.notification-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  margin-top: 0.5rem;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.notification-dropdown.show {
  display: block;
}

.notification-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.notification-list {
  max-height: 250px;
  overflow-y: auto;
}

.notification-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: block;
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 0.825rem;
  line-height: 1.4;
}

.notification-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item-title {
  font-weight: 600;
  color: #a5b4fc;
  margin-bottom: 0.15rem;
  font-size: 0.85rem;
}

/* Cards & Grid */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.primary { background: rgba(99, 102, 241, 0.15); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }

.stat-info h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-info p {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

/* Forms & Tables Layout */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

th {
  background: rgba(15, 23, 42, 0.4);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  white-space: nowrap; /* Mencegah teks badge pecah baris */
}

.badge.hadir { background: var(--success-bg); color: #6ee7b7; }
.badge.telat { background: var(--warning-bg); color: #fcd34d; }
.badge.alpa { background: var(--danger-bg); color: #fca5a5; }
.badge.belum-absen { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition);
}

select.form-control {
  background-image: url("data:image/svg+xml;utf8,<svg fill='%2394a3b8' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 32px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

select option {
  background-color: #1e293b;
  color: var(--text-primary);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: rgba(15, 23, 42, 0.8);
}

/* Login Page Styling */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(30, 41, 59, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Layout split */
.layout-split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .layout-split {
    grid-template-columns: 1fr;
  }
}

/* Log Card (RFID last tap monitoring) */
.log-item {
  background: rgba(15, 23, 42, 0.4);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.log-item:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.log-uid {
  font-family: monospace;
  font-weight: bold;
  color: var(--info);
  font-size: 1rem;
}

.log-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-success { background: var(--success-bg); color: #a7f3d0; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-danger { background: var(--danger-bg); color: #fecaca; border: 1px solid rgba(239, 68, 68, 0.2); }

/* Footer */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  background: rgba(15, 23, 42, 0.4);
}

/* ================= MEDIA QUERIES UNTUK RESPONSIVITAS HP ================= */
@media (max-width: 1024px) {
  /* Mencegah seluruh halaman bergeser ke samping */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  .container {
    padding: 1rem;
    width: 100%;
    max-width: 100%;
  }
  
  /* Ubah grid ke flex agar tidak terjadi bug lebar content pada CSS Grid */
  .layout-split {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 1.5rem;
  }

  .card {
    min-width: 0;
    width: 100%;
    overflow: hidden; /* Potong konten yang meluber keluar dari kartu */
  }

  .navbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    height: auto;
    padding: 1rem 0.5rem;
    gap: 0.75rem;
  }

  .logo {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.02em;
  }

  .nav-links {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
    margin: 0;
  }

  .nav-links li {
    width: auto;
  }

  .nav-links a {
    display: inline-block;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border-radius: 8px;
  }

  .login-wrapper {
    min-height: 75vh;
    padding: 1rem;
  }

  .login-card {
    padding: 1.75rem 1.25rem;
    border-radius: 20px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  /* Kunci scroll hanya pada kontainer tabel, bukan satu halaman */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto !important; /* Paksa aktifkan scroll horizontal */
    -webkit-overflow-scrolling: touch;
    margin-top: 0.5rem;
  }

  .table-responsive table {
    min-width: 600px; /* Ukuran lebar minimal tabel */
    width: 100%;
  }

  .table-responsive th, 
  .table-responsive td {
    white-space: nowrap; /* Hindari teks terpotong ke bawah */
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  h2 {
    font-size: 1.45rem;
    text-align: center;
    line-height: 1.35;
  }

  .logo {
    font-size: 1.1rem !important;
    font-weight: 700;
    letter-spacing: 0.01em;
    flex-direction: column;
    gap: 0.1rem;
    text-align: center;
  }
  
  .logo span {
    font-size: 0.9rem;
  }

  main > div[style*="margin-bottom: 2rem"] {
    text-align: center;
    margin-bottom: 1.5rem !important;
  }

  main > div[style*="margin-bottom: 2rem"] p {
    font-size: 0.9rem;
    line-height: 1.45;
    margin-top: 0.4rem;
  }
  
  .grid-stats {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
    flex-direction: row;
    text-align: left;
    align-items: center;
    gap: 1rem;
    border-radius: 12px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    border-radius: 10px;
  }

  .stat-info h3 {
    font-size: 0.75rem;
  }

  .stat-info p {
    font-size: 1.4rem;
    margin-top: 0.1rem;
  }

  .login-logo h1 {
    font-size: 1.35rem;
  }

  .card {
    padding: 1.1rem;
    border-radius: 12px;
  }

  /* Agar tabel tidak memakan tempat berlebih */
  .table-responsive {
    margin-top: 0.5rem;
  }
}

/* ================= MEDIA QUERIES UNTUK TAMPILAN LAPTOP (1024px - 1300px) ================= */
@media (min-width: 1025px) and (max-width: 1300px) {
  .logo span {
    display: none; /* Sembunyikan 'PDF ANWAARUNNAJAAH' agar logo lebih pendek */
  }
  
  .nav-links {
    gap: 0.6rem; /* Perkecil jarak antar menu */
  }

  .nav-links a {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem; /* Sedikit perkecil ukuran font menu */
  }
}
