/* ============================================================
   QR Smart Attendance — Main Stylesheet
   Theme: Blue + Purple Gradient | Glassmorphism | Modern UI
   ============================================================ */

/* ---- Variables ---- */
:root {
  --primary:       #4f46e5;
  --primary-dark:  #3730a3;
  --primary-light: #818cf8;
  --secondary:     #7c3aed;
  --accent:        #06b6d4;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;

  --gradient:      linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #06b6d4 100%);
  --gradient-soft: linear-gradient(135deg, rgba(79,70,229,.15) 0%, rgba(124,58,237,.15) 100%);

  --sidebar-w:     260px;
  --topbar-h:      64px;

  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow:        0 4px 16px rgba(79,70,229,.12);
  --shadow-lg:     0 8px 32px rgba(79,70,229,.18);

  --radius:        14px;
  --radius-sm:     8px;
  --radius-lg:     20px;
  --transition:    .25s cubic-bezier(.4,0,.2,1);
}

/* Dark Mode */
[data-bs-theme="dark"] {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --border:    #334155;
  --text:      #f1f5f9;
  --text-muted:#94a3b8;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }

/* ============================================================
   LAYOUT
   ============================================================ */

.wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}

.page-content {
  padding: 24px;
  flex: 1;
  margin-top: var(--topbar-h);
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
  color: #e0e7ff;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
  transition: transform var(--transition), width var(--transition);
  box-shadow: 4px 0 24px rgba(0,0,0,.25);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  width: 44px; height: 44px;
  background: var(--gradient);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79,70,229,.4);
}
.brand-name { display: block; font-weight: 700; font-size: 13px; color: #fff; line-height: 1.2; }
.brand-sub  { display: block; font-size: 10px; color: #a5b4fc; }
.sidebar-close { background: none; border: none; color: #a5b4fc; font-size: 18px; margin-left: auto; }

/* User info */
.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: rgba(255,255,255,.05);
  margin: 10px 12px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 10px; background: rgba(99,102,241,.4) !important; padding: 2px 8px; }

/* Nav */
.sidebar-nav { list-style: none; padding: 8px 0; margin: 0; flex: 1; }
.nav-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: #6366f1; padding: 14px 20px 6px;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; color: #c7d2fe;
  text-decoration: none; border-radius: 10px; margin: 2px 10px;
  transition: all var(--transition); font-size: 13.5px;
  position: relative;
}
.sidebar-nav .nav-link i { font-size: 17px; flex-shrink: 0; }
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.1); color: #fff;
  transform: translateX(4px);
}
.sidebar-nav .nav-link.active {
  background: var(--gradient);
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px rgba(79,70,229,.4);
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer .nav-link { margin: 0; color: #f87171 !important; }
.sidebar-footer .nav-link:hover { background: rgba(239,68,68,.15) !important; }

/* Collapsed state */
body.sidebar-collapsed .sidebar { width: 70px; }
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .sidebar-user .user-info,
body.sidebar-collapsed .sidebar .nav-link span,
body.sidebar-collapsed .sidebar .nav-label,
body.sidebar-collapsed .sidebar .badge { display: none; }
body.sidebar-collapsed .sidebar-brand { padding: 20px 12px; }
body.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding: 12px 0; margin: 2px 8px; }
body.sidebar-collapsed .main-content { margin-left: 70px; }

/* Overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1035;
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */

.topbar {
  position: fixed; top: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1030;
  transition: left var(--transition);
  box-shadow: var(--shadow-sm);
}
body.sidebar-collapsed .topbar { left: 70px; }

.topbar-left, .topbar-right {
  display: flex; align-items: center; gap: 8px;
}
.topbar-btn {
  width: 40px; height: 40px;
  border: none; background: none; border-radius: 10px;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--gradient-soft); color: var(--primary); }
.topbar-clock {
  display: flex; align-items: center;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  background: var(--gradient-soft); padding: 6px 14px; border-radius: 20px;
}
.badge-dot {
  position: absolute; top: 5px; right: 5px;
  min-width: 17px; height: 17px; font-size: 9px;
  background: var(--danger); color: #fff;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; border: 2px solid var(--surface);
}
.topbar-profile {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border: none; border-radius: 12px;
  background: none; cursor: pointer; color: var(--text);
  transition: background var(--transition);
}
.topbar-profile:hover { background: var(--gradient-soft); }
.profile-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gradient); color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,70,229,.3);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.profile-role  { font-size: 11px; color: var(--text-muted); }

/* Notification dropdown */
.notification-dropdown { width: 320px; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); }
.dropdown-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-item {
  display: flex !important; gap: 12px; align-items: flex-start;
  padding: 10px 16px !important; border-bottom: 1px solid var(--border);
}
.notif-item.unread { background: rgba(79,70,229,.04); }
.notif-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.notif-icon.warning  { background: rgba(245,158,11,.15); color: #f59e0b; }
.notif-icon.success  { background: rgba(16,185,129,.15);  color: #10b981; }
.notif-icon.error    { background: rgba(239,68,68,.15);   color: #ef4444; }
.notif-icon.info     { background: rgba(59,130,246,.15);  color: #3b82f6; }
.notif-title { font-size: 13px; font-weight: 600; }
.notif-msg   { color: var(--text-muted); }
.notif-time  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  background: none; border-bottom: 1px solid var(--border);
  padding: 16px 20px; font-weight: 600;
}

/* Stat Cards */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; align-items: center; gap: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  overflow: hidden;
  position: relative;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 56px; height: 56px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(79,70,229,.12);  color: var(--primary); }
.stat-icon.purple { background: rgba(124,58,237,.12); color: var(--secondary); }
.stat-icon.green  { background: rgba(16,185,129,.12); color: var(--success); }
.stat-icon.yellow { background: rgba(245,158,11,.12); color: var(--warning); }
.stat-icon.cyan   { background: rgba(6,182,212,.12);  color: var(--accent); }
.stat-icon.red    { background: rgba(239,68,68,.12);  color: var(--danger); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-change { font-size: 12px; font-weight: 600; margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Glassmorphism Cards */
.glass-card {
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.4);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
[data-bs-theme="dark"] .glass-card {
  background: rgba(30,41,59,.7);
  border-color: rgba(255,255,255,.08);
}

/* ============================================================
   TABLES
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.table {
  background: var(--surface);
  margin-bottom: 0;
}
.table thead th {
  background: var(--gradient-soft);
  color: var(--primary-dark);
  font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--border);
  padding: 14px 16px; white-space: nowrap;
}
[data-bs-theme="dark"] .table thead th { color: var(--primary-light); }
.table tbody td { padding: 12px 16px; vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--gradient-soft); }

/* ============================================================
   FORMS
   ============================================================ */

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.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: 13px; margin-bottom: 6px; }
.input-group-text {
  background: var(--gradient-soft); border-color: var(--border);
  color: var(--primary);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px;
  padding: 8px 18px; transition: all var(--transition);
  border: none;
}
.btn-primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,.3);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(79,70,229,.45); transform: translateY(-1px); }
.btn-success  { background: var(--success); color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-info     { background: var(--info);    color: #fff; }
.btn-outline-primary { border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--gradient); color: #fff; border-color: transparent; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }

/* ============================================================
   BADGES
   ============================================================ */

.badge { font-weight: 600; font-size: 11px; padding: 4px 10px; border-radius: 20px; }
.badge.bg-success { background: var(--success) !important; }
.badge.bg-danger  { background: var(--danger)  !important; }
.badge.bg-warning { background: var(--warning) !important; color: #fff !important; }
.badge.bg-info    { background: var(--info)    !important; }

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h4 { margin: 0; font-weight: 700; font-size: 20px; }
.breadcrumb { font-size: 12px; margin: 0; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ============================================================
   QR SCANNER PAGE
   ============================================================ */

.scanner-wrapper {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
}
#qr-reader { width: 100% !important; border: none !important; }
#qr-reader video { border-radius: var(--radius-sm); }
.scan-result-card {
  border-radius: var(--radius);
  padding: 20px;
  animation: slideIn .4s ease;
}
.scan-result-card.present  { background: rgba(16,185,129,.1);  border: 2px solid var(--success); }
.scan-result-card.late     { background: rgba(245,158,11,.1);  border: 2px solid var(--warning); }
.scan-result-card.error    { background: rgba(239,68,68,.1);   border: 2px solid var(--danger); }
.scan-result-card.duplicate{ background: rgba(59,130,246,.1); border: 2px solid var(--info); }

/* ============================================================
   QR CARD (student)
   ============================================================ */

.qr-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.qr-card img { border-radius: 12px; border: 4px solid var(--border); }
.qr-student-name { font-weight: 800; font-size: 16px; margin-top: 14px; }
.qr-student-id   { color: var(--primary); font-weight: 600; font-size: 13px; }

/* ============================================================
   DASHBOARD HERO
   ============================================================ */

.dashboard-hero {
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}
.dashboard-hero::after {
  content: '';
  position: absolute; right: -40px; top: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.dashboard-hero::before {
  content: '';
  position: absolute; right: 60px; bottom: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.hero-greeting { font-size: 24px; font-weight: 800; }
.hero-sub { opacity: .8; font-size: 14px; }

/* ============================================================
   ATTENDANCE HEATMAP
   ============================================================ */

.heatmap-cell {
  width: 14px; height: 14px; border-radius: 3px;
  display: inline-block; margin: 1px;
  transition: transform var(--transition);
}
.heatmap-cell:hover { transform: scale(1.4); cursor: pointer; }
.heatmap-0 { background: var(--border); }
.heatmap-1 { background: rgba(79,70,229,.25); }
.heatmap-2 { background: rgba(79,70,229,.50); }
.heatmap-3 { background: rgba(79,70,229,.75); }
.heatmap-4 { background: var(--primary); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%; max-width: 440px;
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
}
[data-bs-theme="dark"] .login-card { background: rgba(30,41,59,.96); }
.login-logo {
  width: 72px; height: 72px;
  background: var(--gradient);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #fff; margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(79,70,229,.4);
}
.login-title { font-size: 24px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.login-sub   { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 30px; }

/* ============================================================
   UTILITY
   ============================================================ */

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--gradient); color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* Animations */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: .5; }
}
.animate-in { animation: slideIn .35s ease; }
.pulse      { animation: pulse 2s infinite; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1050;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0 !important; }
  .topbar { left: 0 !important; }
  .page-content { padding: 16px; }
}

@media (max-width: 575.98px) {
  .stat-card { padding: 16px; }
  .stat-value { font-size: 22px; }
  .dashboard-hero { padding: 20px; }
  .hero-greeting  { font-size: 18px; }
  .login-card { padding: 30px 20px; }
}
