/* ================================================
   SMPN 1 Kandat – Admin UI
   Design: clean, neutral, professional
   ================================================ */

:root {
  --primary:    #1a56db;
  --primary-dk: #1240a8;
  --sidebar-bg: #111827;
  --sidebar-w:  260px;
  --header-h:   60px;
  --text:       #111827;
  --text-muted: #6b7280;
  --border:     #e5e7eb;
  --bg:         #f3f4f6;
  --white:      #ffffff;
  --success:    #059669;
  --danger:     #dc2626;
  --warning:    #d97706;
  --info:       #0284c7;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9d0d8; border-radius: 10px; }

/* ================================================
   LAYOUT
   ================================================ */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .school-name {
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar-brand .school-sub {
  color: #9ca3af;
  font-size: .72rem;
  margin-top: 3px;
}

.sidebar-brand .brand-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  font-size: 1.1rem;
  color: #fff;
  font-weight: 800;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 16px 16px 6px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6b7280;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #d1d5db;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,.05);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(26,86,219,.2);
  color: #fff;
  border-left-color: var(--primary);
}

.nav-item svg, .nav-item .nav-icon {
  width: 18px; height: 18px; flex-shrink: 0; opacity: .8;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
}

.sidebar-user .avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user .user-info .name {
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
}

.sidebar-user .user-info .role {
  color: #9ca3af;
  font-size: .72rem;
}

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top header ── */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex; align-items: center; gap: 14px;
}

.topbar-right {
  display: flex; align-items: center; gap: 12px;
}

.btn-menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
}

.page-title-bar {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem;
  color: var(--text-muted);
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb span { color: var(--text); font-weight: 500; }

/* ── Page body ── */
.page-body {
  flex: 1;
  padding: 24px;
}

/* ================================================
   CARDS
   ================================================ */

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-card .stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-card .stat-icon.green  { background: #f0fdf4; color: var(--success); }
.stat-card .stat-icon.orange { background: #fffbeb; color: var(--warning); }
.stat-card .stat-icon.red    { background: #fef2f2; color: var(--danger);  }
.stat-card .stat-icon.indigo { background: #eef2ff; color: #4f46e5; }

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: .78rem;
  color: var(--text-muted);
}

/* ================================================
   BUTTONS
   ================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:focus { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-lg { padding: 10px 22px; font-size: .95rem; }

.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }

.btn-secondary {
  background: #fff; color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { background: #f9fafb; }

.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; }

.btn-success {
  background: var(--success); color: #fff; border-color: var(--success);
}
.btn-success:hover { background: #047857; }

.btn-warning {
  background: var(--warning); color: #fff; border-color: var(--warning);
}
.btn-warning:hover { background: #b45309; }

.btn-outline {
  background: transparent; color: var(--primary); border-color: var(--primary);
}
.btn-outline:hover { background: #eff6ff; }

/* ================================================
   TABLES
   ================================================ */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  background: #f9fafb;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tbody tr:hover { background: #fafafa; }

.table-actions { display: flex; gap: 6px; }

/* ================================================
   FORMS
   ================================================ */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-control::placeholder { color: #9ca3af; }

select.form-control { appearance: none; 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 10px center; padding-right: 32px; }

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ================================================
   BADGES / STATUS
   ================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}

.badge-hadir     { background: #dcfce7; color: #166534; }
.badge-terlambat { background: #fff7ed; color: #c2410c; }
.badge-sakit     { background: #fef3c7; color: #92400e; }
.badge-izin      { background: #dbeafe; color: #1e40af; }
.badge-alpha     { background: #fee2e2; color: #991b1b; }
.badge-dinas     { background: #e0e7ff; color: #3730a3; }
.badge-blue      { background: #dbeafe; color: #1e40af; }
.badge-green     { background: #dcfce7; color: #166534; }
.badge-gray      { background: #f3f4f6; color: #374151; }

/* ================================================
   ALERTS / FLASH
   ================================================ */

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}

.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fed7aa; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ================================================
   ATTENDANCE INPUT TABLE
   ================================================ */

.absen-table td, .absen-table th { padding: 8px 12px; }

.absen-radio-group {
  display: flex; gap: 4px; flex-wrap: wrap;
}

.absen-radio-group input[type=radio] { display: none; }

.absen-radio-group label {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .12s;
  background: #f3f4f6;
  color: var(--text-muted);
}

.absen-radio-group input[value=Hadir]:checked ~ label.l-hadir,
.absen-radio-group label.l-hadir:hover { background: #dcfce7; color: #166534; border-color: #86efac; }
.absen-radio-group input[value=Sakit]:checked ~ label.l-sakit,
.absen-radio-group label.l-sakit:hover { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.absen-radio-group input[value=Izin]:checked  ~ label.l-izin,
.absen-radio-group label.l-izin:hover  { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.absen-radio-group input[value=Alpha]:checked ~ label.l-alpha,
.absen-radio-group label.l-alpha:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.absen-radio-group input[value="Dinas Luar"]:checked ~ label.l-dinas,
.absen-radio-group label.l-dinas:hover { background: #e0e7ff; color: #3730a3; border-color: #a5b4fc; }

/* Radio label needs to follow the input – use JS approach instead */
.status-btn {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #e5e7eb;
  background: #f9fafb;
  color: var(--text-muted);
  transition: all .12s;
}

.status-btn:hover, .status-btn.active { transform: none; }
.status-btn.hadir.active      { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-btn.terlambat.active  { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.status-btn.sakit.active      { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.status-btn.izin.active       { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.status-btn.alpha.active      { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.status-btn.dinas.active      { background: #e0e7ff; color: #3730a3; border-color: #a5b4fc; }

/* ================================================
   SCHEDULE / JADWAL
   ================================================ */

.jadwal-grid {
  display: grid;
  grid-template-columns: 90px repeat(6,1fr);
  gap: 0;
  font-size: .8rem;
}

.jadwal-slot {
  border: 1px solid var(--border);
  padding: 6px 8px;
  min-height: 52px;
  background: #fff;
}

.jadwal-slot.header {
  background: #f9fafb;
  font-weight: 600;
  font-size: .75rem;
  text-align: center;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.jadwal-lesson {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: .75rem;
  margin-bottom: 2px;
}

.jadwal-lesson .mapel { font-weight: 600; color: #1e40af; }
.jadwal-lesson .guru  { color: #6b7280; }

/* ================================================
   PAGINATION (simple)
   ================================================ */

.pagination {
  display: flex; gap: 4px; align-items: center;
  padding-top: 16px;
}

.page-link {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .8rem;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition: background .12s;
}

.page-link:hover { background: #f3f4f6; text-decoration: none; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ================================================
   EMPTY STATE
   ================================================ */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: .5;
}

.empty-state h4 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.empty-state p { font-size: .85rem; }

/* ================================================
   LOGIN PAGE
   ================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo .logo-box {
  width: 54px; height: 54px;
  background: var(--primary);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.login-logo p {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ================================================
   UTILITY
   ================================================ */

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.mb-0 { margin-bottom: 0; }

.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2          { gap: 8px; }
.gap-3          { gap: 12px; }
.flex-wrap      { flex-wrap: wrap; }

.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .82rem; }
.text-xs     { font-size: .75rem; }
.fw-600      { font-weight: 600; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.w-100 { width: 100%; }

.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Print ── */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .btn-menu-toggle { display: flex; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row  { grid-template-columns: 1fr; }
}
