/* Predigsi - MTs. YPPMI Design System (Aligned with SIWAPEL Standard) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');

:root {
  --primary: #047857;
  --primary-hover: #065f46;
  --primary-light: #d1fae5;
  --primary-glow: rgba(4, 120, 87, 0.25);
  --secondary: #059669;
  --secondary-light: #ecfdf5;
  --accent-gold: #c5a866;
  --accent-gold-light: #fef3c7;
  --accent-gold-dark: #b45309;
  --teal-accent: #0d9488;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-dark: #0f172a;
  
  --text-main: #0f172a;
  --text-muted: #334155;
  --text-light: #64748b;
  
  --border-color: #cbd5e1;
  --border-focus: #047857;
  
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --info: #0284c7;
  --info-light: #e0f2fe;
  --success: #059669;
  --success-light: #d1fae5;

  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgba(4, 120, 87, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Layout Utilities */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* Sidebar Styled after SIWAPEL Standards */
.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #091e1d 0%, #064e3b 55%, #022c22 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  position: relative;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  padding: 2px;
  object-fit: contain;
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.4);
  border: 1px solid rgba(197, 168, 102, 0.4);
}

.sidebar-brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #ffffff;
  line-height: 1.2;
}

.sidebar-brand-subtitle {
  font-size: 11px;
  color: #34d399;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #34d399;
  font-weight: 800;
  padding: 14px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: #e2e8f0;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border: 1px solid #10b981;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.45);
  font-weight: 700;
}

.nav-item.active svg {
  color: #ffffff;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 99px;
  background: #d97706;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

.main-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: #f8fafc;
}

/* Top Navbar Styled after SIWAPEL Dark Header Standard */
.topbar {
  background: linear-gradient(135deg, #091e1d 0%, #032e26 50%, #0f172a 100%) !important;
  border-bottom: 1px solid rgba(16, 185, 129, 0.3) !important;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  color: #ffffff;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 12px;
}

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

.btn-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.btn-mobile-toggle:hover, .btn-mobile-toggle:active {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
}

.topbar-brand-mobile {
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
}

.topbar-logo-mobile {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  border: 1.5px solid #c5a866;
}

.topbar-title-mobile {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.live-pill .pill-text-compact {
  display: none;
}

#online-db-pill {
  background: rgba(5, 150, 105, 0.25);
  color: #6ee7b7;
  border-color: rgba(110, 231, 183, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}

#online-db-pill:hover {
  background: rgba(5, 150, 105, 0.4);
  border-color: #6ee7b7;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
  animation: pulse-dot 1.8s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.topbar-clock {
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-clock .clock-compact {
  display: none;
}

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

.user-profile-wrapper {
  position: relative;
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  padding: 4px 12px 4px 5px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  color: #ffffff;
  user-select: none;
  transition: all 0.2s ease;
  max-width: 250px;
}

.user-profile-trigger:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #7e22ce 0%, #047857 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.topbar-user-info {
  text-align: left;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar-user-name {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.topbar-user-badge-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.topbar-user-chevron {
  font-size: 10px;
  color: #34d399;
  margin-left: 2px;
  flex-shrink: 0;
}

/* User Dropdown Menu */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  max-width: calc(100vw - 20px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
  padding: 16px;
  z-index: 1000;
  text-align: left;
}

/* Sidebar Backdrop on Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Cards & Containers */
.page-body {
  padding: 28px;
  flex: 1;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-body {
  padding: 24px;
}

/* Stats Cards */
.stat-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--secondary); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.gold::before { background: var(--accent-gold); }

.stat-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 86, 91, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 86, 91, 0.35);
}

.btn-secondary {
  background: var(--secondary);
  color: #ffffff;
}
.btn-secondary:hover {
  background: #047857;
}

.btn-gold {
  background: linear-gradient(135deg, #d4af37 0%, #c5a866 100%);
  color: #1e293b;
  font-weight: 700;
}
.btn-gold:hover {
  filter: brightness(1.06);
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background: #be123c;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #ffe4e6; color: #be123c; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-muted   { background: #f1f5f9; color: #475569; }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* Table Scroll Container (Freeze Header & Scroll Data Rows) */
.table-responsive-freeze {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  min-height: 280px;
  position: relative;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.table-responsive-freeze::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-responsive-freeze::-webkit-scrollbar-track {
  background: #f8fafc;
}

.table-responsive-freeze::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
  border: 2px solid #f8fafc;
}

.table-responsive-freeze::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Table with Sticky Freeze Header */
.custom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.custom-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

.custom-table th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f1f5f9;
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #0f172a;
  border-bottom: 2px solid #cbd5e1;
  box-shadow: inset 0 -2px 0 #cbd5e1, 0 3px 6px -2px rgba(15, 23, 42, 0.08);
}

.custom-table td {
  padding: 14px 18px;
  font-size: 13px;
  color: var(--text-main);
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  background: #ffffff;
}

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

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: #ffffff;
  border-radius: var(--radius-xl);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.97);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  min-width: 300px;
  max-width: 420px;
  animation: slideIn 0.3s ease forwards;
}

.toast.success { border-left-color: var(--secondary); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Kiosk Gate Viewfinder & Scanner */
.scanner-box {
  background: #021a1b;
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(197, 168, 102, 0.4);
  box-shadow: 0 10px 30px rgba(0, 86, 91, 0.3);
}

.scanner-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #10b981, #d4af37, transparent);
  box-shadow: 0 0 12px #10b981;
  animation: scan-line 2.2s infinite ease-in-out;
}

@keyframes scan-line {
  0% { top: 10%; opacity: 0.2; }
  50% { top: 85%; opacity: 1; }
  100% { top: 10%; opacity: 0.2; }
}

/* Student ID Card Print Styling */
.student-card-badge {
  width: 320px;
  height: 190px;
  background: linear-gradient(135deg, #022c22 0%, #064e3b 60%, #047857 100%);
  border-radius: 14px;
  color: white;
  padding: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(197, 168, 102, 0.4);
}

.student-card-badge::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(197, 168, 102, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

/* Print styles */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .sidebar, .topbar, .btn, .no-print {
    display: none !important;
  }
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
  .page-body {
    padding: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
  }
  .print-only {
    display: block !important;
  }
}

.print-only {
  display: none;
}

/* =========================================================================
   COMPREHENSIVE RESPONSIVE DESIGN (TABLET & MOBILE OPTIMIZATIONS)
   ========================================================================= */

@media (max-width: 992px) {
  html, body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .app-container {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .main-content {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .sidebar {
    position: fixed !important;
    top: 0;
    bottom: 0;
    height: 100vh !important;
    height: 100dvh !important;
    left: -290px !important;
    width: 280px !important;
    z-index: 1000 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  .sidebar.open {
    left: 0 !important;
  }

  .sidebar.open ~ .sidebar-backdrop,
  .sidebar.open + .sidebar-backdrop,
  .sidebar-backdrop.active {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .btn-mobile-toggle,
  #mobile-menu-btn {
    display: inline-flex !important;
  }

  .topbar-brand-mobile {
    display: inline-flex !important;
  }

  .topbar {
    padding: 10px 16px !important;
  }

  .topbar-user-name {
    max-width: 110px;
  }
}

@media (max-width: 768px) {
  .page-body {
    padding: 16px 12px !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .topbar {
    padding: 8px 12px !important;
    gap: 8px !important;
  }

  .topbar-left {
    gap: 8px !important;
  }

  /* Compact mode for status pills */
  .live-pill {
    padding: 4px 8px !important;
    font-size: 10.5px !important;
  }
  .live-pill .pill-text-full {
    display: none !important;
  }
  .live-pill .pill-text-compact {
    display: inline !important;
  }

  /* Compact clock */
  .topbar-clock {
    font-size: 11px !important;
    padding: 3px 8px !important;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  .topbar-clock .clock-full {
    display: none !important;
  }
  .topbar-clock .clock-compact {
    display: inline !important;
  }

  /* Compact User Profile */
  .user-profile-trigger {
    padding: 4px 8px 4px 4px !important;
    gap: 6px !important;
    border-radius: 99px !important;
    max-width: 130px !important;
  }
  .topbar-user-badge-wrap {
    display: none !important;
  }
  .topbar-user-name {
    font-size: 11.5px !important;
    max-width: 70px !important;
  }

  /* User Dropdown Menu Alignment */
  .user-dropdown-menu {
    width: 290px !important;
    max-width: calc(100vw - 24px) !important;
    right: 0 !important;
  }

  /* Prevent card / layout containers from overflowing horizontally */
  .card {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .card-header {
    padding: 14px 16px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .card-body {
    padding: 16px 14px !important;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 6px 10px !important;
  }

  /* On narrow phone screens, hide the secondary MySQL pill from topbar, keep Server pill and clock */
  #online-db-pill {
    display: none !important;
  }

  .topbar-brand-mobile {
    gap: 6px !important;
  }
  .topbar-title-mobile {
    font-size: 14px !important;
  }
  .topbar-logo-mobile {
    width: 24px !important;
    height: 24px !important;
  }

  /* User profile becomes Avatar circle + chevron for ultra-clean look */
  .topbar-user-info {
    display: none !important;
  }
  .user-profile-trigger {
    padding: 3px 6px 3px 3px !important;
    background: rgba(255, 255, 255, 0.15) !important;
  }
  .topbar-avatar {
    width: 28px !important;
    height: 28px !important;
    font-size: 11px !important;
  }
}

/* =========================================================================
   SSO LOGIN VIEW & USER PROFILE DROPDOWN STYLES
   ========================================================================= */

/* SSO Login Page Styles */
.sso-login-wrapper {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-image: url('../images/bg-madrasah.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  position: relative;
  overflow: hidden;
}

.sso-login-wrapper .bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(2, 44, 34, 0.45), rgba(15, 23, 42, 0.55));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1;
}

.sso-login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.5);
  padding: 34px 28px 24px;
  position: relative;
  z-index: 10;
  overflow: hidden;
  animation: ssoCardFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.sso-card-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #059669, #C5A866, #0284c7);
}

@keyframes ssoCardFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sso-btn-glow {
  width: 100%;
  padding: 13px 20px;
  background: linear-gradient(135deg, #047857 0%, #064e3b 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 8px 16px -4px rgba(4, 120, 87, 0.35);
  text-decoration: none;
}

.sso-btn-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px -4px rgba(4, 120, 87, 0.45);
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
}

.sso-role-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.sso-role-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.sso-role-card:hover {
  background: #ffffff;
  border-color: #047857;
  box-shadow: 0 4px 10px rgba(4, 120, 87, 0.1);
  transform: translateY(-1px);
}

.sso-role-card.active {
  background: #ecfdf5;
  border-color: #059669;
}

/* User Profile Dropdown in Topbar */
.user-profile-wrapper {
  position: relative;
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  padding: 5px 12px 5px 6px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: all 0.2s ease;
  color: #ffffff;
}

.user-profile-trigger:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 16px 32px -8px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.08);
  padding: 16px;
  z-index: 1000;
  display: none !important;
  animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown-menu.active {
  display: block !important;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-dropdown-header {
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 12px;
}

.user-dropdown-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.user-dropdown-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.user-dropdown-item.active {
  background: #ecfdf5;
  color: #065f46;
  font-weight: 600;
}

/* Role Badges */
.badge-purple {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.badge-gold {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-muted {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* WhatsApp Direct Link Badges */
.wa-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #047857 !important;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  font-size: 11.5px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.wa-link-btn:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #065f46 !important;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.18);
  transform: translateY(-1px);
}

.wa-link-btn .wa-arrow {
  font-size: 9.5px;
  color: #059669;
  font-weight: 800;
  margin-left: 2px;
}

.wa-disabled {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #64748b;
  font-size: 11px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Face Recognition Biometrics & Liveness Scanner */
.face-scanner-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 330px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: #020617;
  border: 2px solid #059669;
  box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.3);
}

.face-scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera */
}

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

.face-oval-guide {
  width: 180px;
  height: 230px;
  border: 2.5px dashed rgba(16, 185, 129, 0.85);
  border-radius: 50% 50% 45% 45% / 55% 55% 45% 45%;
  position: relative;
  animation: pulse-oval 2s infinite ease-in-out;
}

.face-oval-guide.success {
  border-color: #10b981;
  border-style: solid;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
}

.face-oval-guide.blink {
  border-color: #f59e0b;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
}

@keyframes pulse-oval {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.03);
    opacity: 1;
  }
}

.face-scanner-laser {
  position: absolute;
  left: 10%;
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #34d399, transparent);
  box-shadow: 0 0 12px #10b981;
  animation: scan-laser 2.4s infinite ease-in-out;
}

@keyframes scan-laser {
  0% { top: 20%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 80%; opacity: 0; }
}

.liveness-badge {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  white-space: nowrap;
  z-index: 10;
}

.liveness-blink-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.liveness-blink-dot.active {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* ==========================================================================
   DASHBOARD OPTIMIZATION (V1.1.9) - TREND CHART & ROMBEL DISTRIBUTION
   ========================================================================== */

/* Custom Slim Scrollbar for Dashboard Containers */
.custom-slim-scroll {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.custom-slim-scroll::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.custom-slim-scroll::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 99px;
}

.custom-slim-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

.custom-slim-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Dashboard Graphical Grid */
.dashboard-graph-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 22px;
}

@media (max-width: 960px) {
  .dashboard-graph-grid {
    grid-template-columns: 1fr;
  }
}

/* Rombel Stat Card in Dashboard */
.rombel-stat-card {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
}

.rombel-stat-card:hover {
  background: #ffffff !important;
  border-color: #10b981 !important;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.12) !important;
}

/* Filter Pills */
.btn-filter-pill {
  transition: all 0.18s ease;
  font-family: inherit;
}

.btn-filter-pill:hover {
  border-color: #059669 !important;
  color: #047857 !important;
}

/* Trend Chart Bars */
.trend-col {
  transition: all 0.2s ease;
}

.trend-bar {
  transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s ease, filter 0.15s ease;
}

.trend-bar:hover {
  transform: scaleY(1.04);
  filter: brightness(1.1);
}
