/* ==========================================================================
   Smart QR Attendance — Hybrid Theme (Dark Navy Sidebar + Light Content)
   ========================================================================== */
:root {
  --navy-950: #0b162c;
  --navy-900: #0f1f3d;
  --navy-800: #162c54;
  --navy-700: #1e3a6e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --cyan-400: #22d3ee;
  --amber-500: #f59e0b;
  --amber-400: #fbbf24;
  --bg-body: #f3f6fb;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --sidebar-w: 265px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* Layout Wrapper */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (Dark Navy) */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: transform 0.25s ease;
  box-shadow: 4px 0 24px rgba(2, 6, 23, 0.18);
}

.sidebar-header {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, var(--teal-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #ffffff;
  text-transform: uppercase;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--cyan-400);
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.nav-section {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.9px;
  color: #64748b;
  text-transform: uppercase;
  margin: 16px 10px 8px;
}

.nav-section:first-child { margin-top: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 3px;
  transition: all 0.16s ease;
}

.nav-link .nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-link.active {
  background: #ffffff;
  color: var(--navy-900);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-badge-qr {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.18);
  color: var(--cyan-400);
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.nav-link.active .nav-badge-qr {
  background: var(--navy-900);
  color: #ffffff;
  border-color: transparent;
}

.sidebar-footer {
  padding: 14px 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.16);
}

.sidebar-clock {
  font-size: 18px;
  font-weight: 800;
  color: var(--amber-400);
  letter-spacing: 0.6px;
}

.sidebar-date {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 10px;
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 9px 10px;
  border-radius: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10.5px;
  color: var(--amber-400);
  font-weight: 600;
}

.btn-logout {
  color: #fda4af;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(244, 63, 94, 0.15);
}

.btn-logout:hover { background: rgba(244, 63, 94, 0.3); color: #fff; }

/* Overlay Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.58);
  z-index: 950;
}

.sidebar-overlay.show { display: block; }

/* Main Content */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 500;
}

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

.menu-toggle {
  display: none;
  background: var(--navy-900);
  color: #fff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
}

.topbar-school {
  font-size: 11px;
  font-weight: 700;
  color: var(--teal-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topbar-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

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

.profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}

.content-body {
  padding: 22px 24px 36px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Welcome Banner */
.hero-banner {
  background: linear-gradient(125deg, var(--navy-900) 0%, #15426d 55%, var(--teal-600) 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: var(--shadow-md);
  margin-bottom: 22px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-amber { background: rgba(251, 191, 36, 0.2); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.4); }
.badge-green { background: rgba(16, 185, 129, 0.22); color: #a7f3d0; border: 1px solid rgba(16, 185, 129, 0.4); }

.hero-title { margin: 0 0 4px; font-size: 23px; font-weight: 800; }
.hero-motto { margin: 0; font-size: 13px; color: #dbeafe; font-style: italic; }

.hero-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-clock-box {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: right;
  backdrop-filter: blur(4px);
}

.hero-clock-time { font-size: 24px; font-weight: 800; letter-spacing: 1px; line-height: 1.1; }
.hero-clock-date { font-size: 11.5px; color: #e0f2fe; margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-amber { background: var(--amber-400); color: #0f172a; }
.btn-teal { background: var(--teal-600); color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-outline { background: #fff; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

/* Section Heading */
.section-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.section-bar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--navy-900);
}

.section-bar p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* KPI Grids */
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid-teacher {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card.c-navy   { background: linear-gradient(135deg, #1e3a8a, #1e40af); color: #fff; border: none; }
.kpi-card.c-green  { background: linear-gradient(135deg, #059669, #10b981); color: #fff; border: none; }
.kpi-card.c-slate  { background: #ffffff; color: var(--text-main); }
.kpi-card.c-orange { background: linear-gradient(135deg, #ea580c, #f97316); color: #fff; border: none; }
.kpi-card.c-sky    { background: linear-gradient(135deg, #0284c7, #0ea5e9); color: #fff; border: none; }
.kpi-card.c-purple { background: linear-gradient(135deg, #7c3aed, #8b5cf6); color: #fff; border: none; }
.kpi-card.c-red    { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; border: none; }

.kpi-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  opacity: 0.9;
}

.kpi-value {
  font-size: 30px;
  font-weight: 800;
  margin: 6px 0 4px;
  line-height: 1.1;
}

.kpi-sub {
  font-size: 12px;
  opacity: 0.88;
}

.kpi-card.c-slate .kpi-label,
.kpi-card.c-slate .kpi-sub { color: var(--text-muted); }

/* Cards & Panels */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 18px;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-title { margin: 0; font-size: 15px; font-weight: 800; }
.card-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.card-body { padding: 18px; }

/* Live Badge */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: #dcfce7;
  color: #166534;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* Status Badges */
.st-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.st-hadir { background: #dcfce7; color: #166534; }
.st-terlambat { background: #fef3c7; color: #92400e; }
.st-izin { background: #dbeafe; color: #1e40af; }
.st-sakit { background: #f3e8ff; color: #6b21a8; }
.st-alpa { background: #fee2e2; color: #991b1b; }
.st-guru { background: #e0f2fe; color: #075985; }
.st-siswa { background: #ede9fe; color: #5b21b6; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data-table th {
  text-align: left;
  padding: 11px 14px;
  background: #f8fafc;
  color: #475569;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-color);
}

table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

table.data-table tr:hover td { background: #f8fafc; }

/* Forms */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  font-size: 13.5px;
  background: #fff;
  color: var(--text-main);
}

.form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 600;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* Live Feed Items */
.feed-list { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  background: #f8fafc;
}

.feed-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.feed-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #2563eb; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.feed-avatar.is-guru { background: #0d9488; }
.feed-name { font-weight: 700; font-size: 13.5px; }
.feed-sub { font-size: 11.5px; color: var(--text-muted); }
.feed-right { text-align: right; flex-shrink: 0; }
.feed-time { font-size: 12px; font-weight: 700; color: #334155; margin-top: 3px; }

/* QR Cards Print Grid */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.qr-id-card {
  background: #fff;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  overflow: hidden;
  text-align: center;
  page-break-inside: avoid;
}

.qr-id-header {
  background: linear-gradient(135deg, var(--navy-900), var(--teal-600));
  color: #fff;
  padding: 10px 12px;
}

.qr-id-school { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; }
.qr-id-type { font-size: 10px; opacity: 0.85; }
.qr-id-body { padding: 14px 12px; }
.qr-box { display: flex; justify-content: center; margin: 6px 0 10px; }
.qr-id-name { font-size: 14px; font-weight: 800; color: var(--navy-900); }
.qr-id-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.qr-id-token { font-family: monospace; font-size: 11.5px; background: #f1f5f9; padding: 3px 8px; border-radius: 6px; display: inline-block; margin-top: 6px; }

/* Login Page */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-950) 0%, var(--navy-800) 55%, var(--teal-600) 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: #ffffff;
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.35);
}

/* Responsive */
@media (max-width: 1100px) {
  .kpi-grid-4, .kpi-grid-teacher { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .content-body { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

@media (max-width: 520px) {
  .kpi-grid-4, .kpi-grid-teacher { grid-template-columns: 1fr; }
}

/* Print Rules */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  .content-body { padding: 0 !important; max-width: none !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; }
}

/* Logo Sekolah, Preview Upload, Kop Surat & Tanda Tangan Cetak */
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
  padding: 3px;
}

.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.logo-preview-box {
  width: 82px;
  height: 82px;
  border-radius: 14px;
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.logo-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.qr-id-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 8px;
  padding: 2px;
  margin: 0 auto 4px;
  display: block;
}

.print-letterhead,
.print-sign {
  display: none;
}

@media print {
  .print-letterhead {
    display: flex !important;
    align-items: center;
    gap: 16px;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 3px double #0f172a;
  }
  .print-lh-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
  }
  .print-lh-text {
    flex: 1;
    text-align: center;
  }
  .print-lh-school {
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .print-lh-meta {
    font-size: 11.5px;
    color: #334155;
    margin-top: 2px;
  }
  .print-sign {
    display: flex !important;
    justify-content: flex-end;
    margin-top: 28px;
    page-break-inside: avoid;
  }
  .print-sign-box {
    width: 240px;
    text-align: left;
    font-size: 12.5px;
  }
}

/* Pagination Bernomor (1 2 3 ... 10) & Mode Edit */
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
}

.page-info {
  font-size: 12.5px;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.page-link:hover:not(.disabled):not(.active) {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.page-link.active {
  background: var(--navy-900);
  color: #ffffff;
  border-color: var(--navy-900);
}

.page-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.page-ellipsis {
  padding: 0 6px;
  color: var(--text-muted);
  font-weight: 700;
}

.card-edit-mode {
  border: 2px solid #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
