/* ===========================================================
   Smart Attendance System - Main Stylesheet
   Modern dashboard UI with sidebar + dark/light mode support
   =========================================================== */

:root {
  --sidebar-width: 250px;
  --topbar-height: 60px;
  --primary: #4361ee;
  --primary-dark: #3247c5;
  --bg-light: #f4f6fb;
  --card-bg-light: #ffffff;
  --text-light: #1f2430;
  --border-light: #e6e9f0;

  --bg-dark: #121826;
  --card-bg-dark: #1b2436;
  --text-dark: #e8ecf5;
  --border-dark: #2b3650;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg-light);
  color: var(--text-light);
  margin: 0;
  transition: background 0.25s ease, color 0.25s ease;
}

[data-bs-theme="dark"] body,
html[data-bs-theme="dark"] body {
  background: var(--bg-dark);
  color: var(--text-dark);
}

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg-light);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1030;
}
html[data-bs-theme="dark"] .topbar {
  background: var(--card-bg-dark);
  border-bottom: 1px solid var(--border-dark);
}

/* ---------- Layout ---------- */
.app-wrapper {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg-light);
  border-right: 1px solid var(--border-light);
  flex-shrink: 0;
  transition: transform 0.25s ease, background 0.25s ease;
}
html[data-bs-theme="dark"] .sidebar {
  background: var(--card-bg-dark);
  border-right: 1px solid var(--border-dark);
}

.sidebar-inner { padding: 16px 10px; position: sticky; top: var(--topbar-height); }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 0.95rem;
  opacity: 0.85;
}
.sidebar-link:hover { background: rgba(67, 97, 238, 0.1); opacity: 1; }
.sidebar-link.active { background: var(--primary); color: #fff; opacity: 1; }

.main-content { flex: 1; padding: 24px; width: 100%; min-width: 0; }

/* ---------- Cards ---------- */
.stat-card {
  background: var(--card-bg-light);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
}
html[data-bs-theme="dark"] .stat-card {
  background: var(--card-bg-dark);
  border: 1px solid var(--border-dark);
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; margin: 0; }
.stat-label { font-size: 0.85rem; opacity: 0.7; margin: 0; }

.card-panel {
  background: var(--card-bg-light);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 24px;
}
html[data-bs-theme="dark"] .card-panel {
  background: var(--card-bg-dark);
  border: 1px solid var(--border-dark);
}

/* ---------- Tables ---------- */
.table { color: inherit; }
html[data-bs-theme="dark"] .table { --bs-table-color: var(--text-dark); --bs-table-bg: transparent; }
.table thead th { border-bottom: 2px solid var(--primary); font-size: 0.85rem; text-transform: uppercase; opacity: 0.75; }

/* ---------- Auth pages ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 18px;
  padding: 40px;
  width: 100%;
  max-width: 430px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-card h3 { font-weight: 700; }
.role-tabs .nav-link { border-radius: 10px; font-weight: 600; }

/* ---------- Class ID badge ---------- */
.class-id-badge {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--primary);
  background: rgba(67,97,238,0.08);
  border: 2px dashed var(--primary);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

#countdownTimer { font-weight: 700; color: #e63946; }

/* ---------- Camera box ---------- */
.camera-box {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid var(--primary);
  background: #000;
}
.camera-box video, .camera-box canvas { width: 100%; display: block; }

/* ---------- Badges ---------- */
.badge-soft-success { background: rgba(25,135,84,0.12); color: #198754; }
.badge-soft-danger { background: rgba(220,53,69,0.12); color: #dc3545; }
.badge-soft-warning { background: rgba(255,193,7,0.15); color: #b8860b; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    z-index: 1020;
    transform: translateX(-100%);
  }
  .sidebar.show { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.2); }
  .main-content { padding: 16px; }
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.text-primary { color: var(--primary) !important; }

.brand-icon { color: var(--primary); }
