/* ── SchoolMaster ERP — Global Stylesheet ── */
:root {
  --sm-primary: #1A6B4A;
  --sm-primary-light: #22884F;
  --sm-primary-soft: #DCF0E8;
  --sm-sidebar-w: 260px;
  --sm-topbar-h: 64px;
  --sm-gold: #C4882A;
  --sm-gold-soft: #FDF2DC;
  --sm-radius: 12px;
  --sm-shadow: 0 2px 12px rgba(14,28,47,.08);
  --sm-shadow-lg: 0 8px 32px rgba(14,28,47,.12);
}

/* ── RESET / BASE ── */
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #F5F7FA; color: #1a2332; }
*, *::before, *::after { box-sizing: border-box; }
a { color: var(--sm-primary); }

/* ── SIDEBAR ── */
#sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sm-sidebar-w);
  background: #0E1C2F; overflow-y: auto; z-index: 1000;
  transition: transform .3s ease; display: flex; flex-direction: column;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-header { padding: 20px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 36px; height: 36px; background: var(--sm-primary); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: #fff; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.brand-name { color: #fff; font-weight: 700; font-size: .95rem; }
.brand-sub  { color: rgba(255,255,255,.4); font-size: .7rem; }

.sidebar-menu { padding: 8px 8px 32px; flex: 1; }
.menu-section { font-size: .65rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.3); padding: 16px 10px 4px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: rgba(255,255,255,.65); text-decoration: none; font-size: .875rem; font-weight: 500;
  transition: all .2s; margin-bottom: 2px; }
.menu-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu-item.active { background: var(--sm-primary); color: #fff; }
.menu-item i { font-size: 1rem; width: 20px; text-align: center; }

/* ── MAIN WRAPPER ── */
#main-wrapper { margin-left: var(--sm-sidebar-w); min-height: 100vh; transition: margin .3s ease; }
body.sidebar-collapsed #sidebar { transform: translateX(-100%); }
body.sidebar-collapsed #main-wrapper { margin-left: 0; }

/* ── TOPBAR ── */
#topbar {
  position: sticky; top: 0; z-index: 900; height: var(--sm-topbar-h);
  background: #fff; border-bottom: 1px solid rgba(14,28,47,.07);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; box-shadow: var(--sm-shadow);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.btn-icon { border: none; background: none; padding: 8px; border-radius: 8px; cursor: pointer;
  color: #5a6e85; transition: background .2s; font-size: 1rem; }
.btn-icon:hover { background: #f0f2f5; color: #1a2332; }

.search-wrap { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #999; font-size: .9rem; }
.search-input { border: 1px solid #e5e7eb; border-radius: 50px; padding: .45rem 1rem .45rem 2.2rem;
  font-size: .875rem; width: 280px; outline: none; transition: border .2s; background: #f5f7fa; }
.search-input:focus { border-color: var(--sm-primary); background: #fff; width: 320px; }
.search-dropdown { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: #fff;
  border-radius: 10px; box-shadow: var(--sm-shadow-lg); display: none; max-height: 300px; overflow-y: auto;
  border: 1px solid rgba(14,28,47,.08); z-index: 9999; }
.search-dropdown.show { display: block; }
.search-result-item { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  font-size: .875rem; transition: background .15s; }
.search-result-item:hover { background: #f5f7fa; }

.notif-badge { position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; background: #dc3545;
  border-radius: 50%; font-size: .6rem; color: #fff; display: flex; align-items: center; justify-content: center; }
.btn-user { display: flex; align-items: center; gap: 8px; border: none; background: none;
  padding: 6px 10px; border-radius: 10px; cursor: pointer; transition: background .2s; }
.btn-user:hover { background: #f5f7fa; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.user-initials { width: 34px; height: 34px; border-radius: 50%; background: var(--sm-primary-soft);
  color: var(--sm-primary); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; }
.user-name { font-size: .85rem; font-weight: 600; color: #1a2332; line-height: 1.2; }
.user-role { font-size: .72rem; color: #8896a7; }

/* ── PAGE CONTENT ── */
#page-content { padding: 24px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: #1a2332; margin: 0; }
.page-sub { color: #8896a7; font-size: .875rem; margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── CARDS ── */
.card { border: 1px solid rgba(14,28,47,.07); border-radius: var(--sm-radius); box-shadow: var(--sm-shadow); }
.card-header { background: #fff; border-bottom: 1px solid rgba(14,28,47,.07);
  padding: 16px 20px; border-radius: var(--sm-radius) var(--sm-radius) 0 0 !important; }
.card-body { padding: 20px; }

/* ── KPI CARDS ── */
.kpi-card { background: #fff; border: 1px solid rgba(14,28,47,.07); border-radius: var(--sm-radius);
  padding: 20px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--sm-shadow); transition: transform .2s, box-shadow .2s; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--sm-shadow-lg); }
.kpi-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center;
  justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.kpi-body { flex: 1; min-width: 0; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: #1a2332; line-height: 1.2; }
.kpi-label { font-size: .78rem; color: #8896a7; font-weight: 500; margin-top: 2px; }
.kpi-link { color: #cdd3da; font-size: 1rem; }
.kpi-link:hover { color: var(--sm-primary); }

/* ── SOFT COLOR UTILITIES ── */
.bg-primary-soft { background: var(--sm-primary-soft) !important; }
.text-primary { color: var(--sm-primary) !important; }
.bg-success-soft { background: #d4edda20 !important; }
.bg-warning-soft { background: var(--sm-gold-soft) !important; }
.bg-danger-soft  { background: #f8d7da20 !important; }
.bg-info-soft    { background: #cce5ff30 !important; }

/* ── AVATARS ── */
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; }

/* ── TABLES ── */
.table th { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: #8896a7; border-bottom-width: 1px; padding: 10px 14px; }
.table td { padding: 12px 14px; vertical-align: middle; font-size: .875rem; }

/* ── FORMS ── */
.form-control, .form-select { border-radius: 8px; border-color: #e2e8f0; font-size: .875rem; }
.form-control:focus, .form-select:focus { border-color: var(--sm-primary); box-shadow: 0 0 0 3px rgba(26,107,74,.12); }
.form-label { font-weight: 600; font-size: .82rem; color: #5a6e85; margin-bottom: .4rem; }

/* ── BUTTONS ── */
.btn-primary { background: var(--sm-primary); border-color: var(--sm-primary); }
.btn-primary:hover { background: var(--sm-primary-light); border-color: var(--sm-primary-light); }
.btn { border-radius: 8px; font-size: .875rem; font-weight: 500; }

/* ── ATTENDANCE STATS ── */
.att-stat span { font-size: 1.6rem; font-weight: 700; display: block; }
.att-stat small { font-size: .75rem; color: #8896a7; }

/* ── AUTH ── */
.auth-body { background: linear-gradient(135deg, #0E1C2F 0%, #1A3A2A 100%); min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-bg { position: fixed; inset: 0; opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-rule='evenodd'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E"); }
.auth-container { position: relative; width: 100%; max-width: 440px; }
.auth-card { background: #fff; border-radius: 20px; padding: 40px; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-logo { width: 64px; height: 64px; background: var(--sm-primary); border-radius: 18px;
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: #fff; margin: 0 auto 16px; }
.auth-title { font-size: 1.4rem; font-weight: 800; color: #1a2332; margin: 0 0 4px; }
.auth-sub  { font-size: .875rem; color: #8896a7; margin: 0; }
.auth-footer { text-align: center; color: rgba(255,255,255,.4); font-size: .8rem; margin-top: 20px; }

/* ── CBT EXAM ── */
.cbt-timer { font-size: 2rem; font-weight: 700; font-family: monospace; color: var(--sm-primary); }
.cbt-timer.danger { color: #dc3545; animation: pulse 1s infinite; }
.question-card { border: 2px solid #e2e8f0; border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.question-card.answered { border-color: var(--sm-primary); background: #f8fdfb; }
.option-label { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 1.5px solid #e2e8f0; border-radius: 10px; cursor: pointer; margin-bottom: 8px;
  transition: all .15s; font-size: .9rem; }
.option-label:hover { border-color: var(--sm-primary); background: var(--sm-primary-soft); }
input[type="radio"]:checked + .option-label { border-color: var(--sm-primary); background: var(--sm-primary-soft); }

/* ── DARK MODE ── */
[data-bs-theme="dark"] body { background: #0f1623; color: #e2e8f0; }
[data-bs-theme="dark"] .card { background: #1a2335; border-color: rgba(255,255,255,.07); }
[data-bs-theme="dark"] .card-header { background: #1a2335; border-color: rgba(255,255,255,.07); }
[data-bs-theme="dark"] #topbar { background: #1a2335; border-color: rgba(255,255,255,.07); }
[data-bs-theme="dark"] .kpi-card { background: #1a2335; border-color: rgba(255,255,255,.07); }
[data-bs-theme="dark"] .page-title { color: #e2e8f0; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background: #111827; border-color: rgba(255,255,255,.1); color: #e2e8f0; }
[data-bs-theme="dark"] .table { color: #e2e8f0; }
[data-bs-theme="dark"] .table-light { background: #111827 !important; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #main-wrapper { margin-left: 0; }
  body.sidebar-open #sidebar { transform: translateX(0); }
  body.sidebar-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }
  .search-input { width: 180px; }
  #page-content { padding: 16px; }
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.notif-menu .dropdown-item { padding: 12px 16px; font-size: .85rem; }
.scanner-frame { border: 3px solid var(--sm-primary); border-radius: 16px; position: relative; overflow: hidden; }
