/* ============================================
   KANTIN SEKOLAH - MAIN STYLESHEET
   ============================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #818cf8;
  --secondary: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --dark: #0f172a;
  --sidebar-bg: #0f172a;
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --card-bg: #ffffff;
  --body-bg: #f1f5f9;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--body-bg);
  color: #1e293b;
  font-size: 0.9rem;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  background-image: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width .3s ease, transform .3s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
  flex-shrink: 0;
}

.brand-name { color: white; font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.brand-sub { color: var(--primary-light); font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; }
.brand-text { overflow: hidden; }

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

.user-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 20px;
  flex-shrink: 0;
}

.user-name { color: white; font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info { overflow: hidden; min-width: 0; }

.badge-role-admin { color: #a78bfa; font-size: .7rem; font-weight: 500; }
.badge-role-bendahara { color: #34d399; font-size: .7rem; font-weight: 500; }
.badge-role-toko { color: #fb923c; font-size: .7rem; font-weight: 500; }
.badge-role-siswa { color: #60a5fa; font-size: .7rem; font-weight: 500; }

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

.sidebar-nav a, .nav-section-title {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  transition: all .2s ease;
  white-space: nowrap;
  margin-bottom: 2px;
}

.nav-section-title {
  color: rgba(255,255,255,.3);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 12px 4px;
  pointer-events: none;
  font-weight: 600;
}

.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: white; }
.sidebar-nav a.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 4px 12px rgba(79,70,229,.4); }
.sidebar-nav a i { width: 18px; text-align: center; font-size: 1rem; flex-shrink: 0; }

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

.logout-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  transition: all .2s;
}
.logout-btn:hover { background: rgba(239,68,68,.15); color: #f87171; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

.top-navbar {
  background: white;
  height: 64px;
  display: flex; align-items: center;
  padding: 0 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  position: sticky; top: 0;
  z-index: 100;
  gap: 16px;
}

.sidebar-toggle {
  background: none; border: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #64748b;
  font-size: 1.1rem;
  transition: all .2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: #f1f5f9; color: var(--primary); }

.navbar-title { font-weight: 600; color: #0f172a; font-size: .95rem; flex: 1; }

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

.notif-btn {
  position: relative;
  background: none; border: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #64748b; font-size: 1.1rem;
  text-decoration: none;
  transition: all .2s;
}
.notif-btn:hover { background: #f1f5f9; color: var(--primary); }
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--danger); color: white;
  font-size: .6rem; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.navbar-user {
  display: flex; align-items: center; gap: 8px;
  color: #475569; font-size: .85rem; font-weight: 500;
}

.page-content { padding: 24px; flex: 1; }

/* ============================================
   CARDS & STATS
   ============================================ */
.stat-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform .2s, box-shadow .2s;
  border: 1px solid var(--border);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

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

.stat-icon.bg-primary-soft { background: #ede9fe; color: var(--primary); }
.stat-icon.bg-success-soft { background: #d1fae5; color: var(--success); }
.stat-icon.bg-warning-soft { background: #fef3c7; color: var(--warning); }
.stat-icon.bg-danger-soft  { background: #fee2e2; color: var(--danger); }
.stat-icon.bg-info-soft    { background: #dbeafe; color: var(--info); }
.stat-icon.bg-cyan-soft    { background: #cffafe; color: var(--secondary); }

.stat-value { font-size: 1.6rem; font-weight: 800; color: #0f172a; line-height: 1.2; }
.stat-label { color: var(--text-muted); font-size: .8rem; font-weight: 500; margin-top: 2px; }
.stat-change { font-size: .75rem; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================
   CARD COMPONENT
   ============================================ */
.card {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px;
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
  display: flex; align-items: center; gap: 8px;
}

.card-title i { color: var(--primary); }
.card-body { padding: 24px; }

/* ============================================
   TABLES
   ============================================ */
.table-container { overflow-x: auto; }

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

.table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

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

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================
   BADGES
   ============================================ */
.badge {
  font-size: .72rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.badge-sukses  { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-gagal   { background: #fee2e2; color: #991b1b; }
.badge-dibatalkan { background: #f1f5f9; color: #475569; }
.badge-selesai { background: #d1fae5; color: #065f46; }
.badge-disetujui { background: #dbeafe; color: #1e40af; }
.badge-ditolak { background: #fee2e2; color: #991b1b; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  border-radius: 8px;
  font-weight: 600;
  font-size: .875rem;
  padding: 8px 18px;
  transition: all .2s;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #0f172a; }
.btn-danger  { background: var(--danger); border-color: var(--danger); }
.btn-info    { background: var(--info); border-color: var(--info); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }

/* ============================================
   FORMS
   ============================================ */
.form-control, .form-select {
  border-radius: 8px;
  border: 1.5px solid var(--border);
  padding: 10px 14px;
  font-size: .875rem;
  transition: all .2s;
  color: #1e293b;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
  outline: none;
}

.form-label { font-weight: 600; font-size: .85rem; color: #374151; margin-bottom: 6px; }

.input-group-text {
  background: #f8fafc;
  border-color: var(--border);
  color: #64748b;
  border-radius: 8px;
}

/* ============================================
   GRADIENT HEADERS
   ============================================ */
.page-header {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 50%, var(--secondary) 100%);
  border-radius: 16px;
  padding: 28px 32px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: -60px; right: 80px;
  width: 240px; height: 240px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
}

.page-header h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.page-header p { opacity: .8; font-size: .9rem; margin: 0; }

/* ============================================
   ALERT FLASH
   ============================================ */
.alert-flash {
  border-radius: 12px;
  font-weight: 500;
  margin-bottom: 20px;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg-shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(79,70,229,.15);
}
.login-bg-shape.s1 { width: 400px; height: 400px; top: -100px; right: -100px; }
.login-bg-shape.s2 { width: 300px; height: 300px; bottom: -80px; left: -80px; background: rgba(6,182,212,.1); }

.login-card {
  background: white;
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.4);
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 28px;
  margin: 0 auto 20px;
}

.login-title { text-align: center; font-size: 1.5rem; font-weight: 800; color: #0f172a; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 32px; }

/* ============================================
   QRIS SCANNER
   ============================================ */
.qr-scanner-box {
  background: #0f172a;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.scanner-viewport {
  width: 100%;
  max-width: 340px;
  height: 300px;
  margin: 0 auto;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

#video { width: 100%; height: 100%; object-fit: cover; }

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

.scanner-frame {
  width: 200px; height: 200px;
  position: relative;
}

.scanner-frame::before, .scanner-frame::after,
.scanner-frame > span::before, .scanner-frame > span::after {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border-color: #4f46e5;
  border-style: solid;
}

.scanner-frame::before { top: 0; left: 0; border-width: 3px 0 0 3px; }
.scanner-frame::after  { top: 0; right: 0; border-width: 3px 3px 0 0; }
.scanner-frame > span::before { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.scanner-frame > span::after  { bottom: 0; right: 0; border-width: 0 3px 3px 0; }

.scanner-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: scan 2s infinite linear;
}

@keyframes scan {
  0%   { top: 0; }
  100% { top: 100%; }
}

/* ============================================
   CHART CONTAINER
   ============================================ */
.chart-container { position: relative; height: 280px; }

/* ============================================
   PAYMENT RESULT CARD
   ============================================ */
.payment-result {
  border-radius: 16px;
  padding: 24px;
  text-align: center;
}

.payment-result.success { background: linear-gradient(135deg, #d1fae5, #a7f3d0); }
.payment-result.error   { background: linear-gradient(135deg, #fee2e2, #fecaca); }

.result-icon { font-size: 3rem; margin-bottom: 12px; }
.result-icon.success { color: var(--success); }
.result-icon.error   { color: var(--danger); }

/* ============================================
   QR CODE DISPLAY
   ============================================ */
.qr-display {
  background: white;
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.08);
  border: 2px solid #f1f5f9;
}

.qr-display img, .qr-display canvas {
  width: 220px; height: 220px;
  border-radius: 12px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: .4; }
.empty-state h6 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: .875rem; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }

  .page-content { padding: 16px; }
  .page-header { padding: 20px; }
  .stat-value { font-size: 1.3rem; }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-content { animation: fadeIn .3s ease; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================
   SALDO DISPLAY
   ============================================ */
.saldo-card {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 20px;
  padding: 28px;
  color: white;
  position: relative;
  overflow: hidden;
}

.saldo-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 150px; height: 150px;
  background: rgba(255,255,255,.08);
  border-radius: 50%;
}

.saldo-label { font-size: .85rem; opacity: .8; margin-bottom: 8px; }
.saldo-value { font-size: 2.2rem; font-weight: 800; }
.saldo-nis { font-size: .8rem; opacity: .7; margin-top: 4px; }

/* ============================================
   TIMELINE / ACTIVITY
   ============================================ */
.activity-item {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

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

.activity-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}

.activity-text { flex: 1; min-width: 0; }
.activity-title { font-size: .875rem; font-weight: 600; color: #0f172a; }
.activity-sub { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.activity-amount { font-weight: 700; font-size: .875rem; white-space: nowrap; }

/* ============================================
   SORTABLE TABLE HEADERS
   ============================================ */
.th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.th-sort:hover { background: #f1f5f9 !important; color: var(--primary); }

.sort-icon {
  display: inline-flex;
  flex-direction: column;
  margin-left: 5px;
  vertical-align: middle;
  opacity: .35;
  font-size: .6rem;
  line-height: 1;
  gap: 1px;
}
.sort-icon.asc  .si-up   { opacity: 1; color: var(--primary); }
.sort-icon.desc .si-down { opacity: 1; color: var(--primary); }
.sort-icon .si-up,
.sort-icon .si-down { display: block; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  flex-wrap: wrap;
}
.page-link {
  border-radius: 7px !important;
  font-size: .8rem;
  font-weight: 600;
  padding: 5px 10px;
  color: #475569;
  border-color: #e2e8f0;
  transition: all .15s;
}
.page-link:hover { background: var(--primary); color: white; border-color: var(--primary); }
.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.page-item.disabled .page-link { opacity: .45; pointer-events: none; }

.per-page-group .btn {
  border-radius: 6px !important;
  font-size: .75rem !important;
  padding: 3px 9px !important;
}

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.filter-bar .form-control,
.filter-bar .form-select {
  font-size: .85rem;
  padding: 7px 12px;
}
