/**
 * SchoolSync ERP — Main CSS Design System
 * VISWABHARATHI WISEWOODS EM HIGH SCHOOL
 *
 * Design: Deep Navy + Teal accent, Dark/Light mode, Material-inspired
 * Typography: Google Fonts — Inter
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Custom Properties (Design Tokens) ──────────────────────────────── */
:root {
  /* Brand Colors */
  --brand-primary: #0f4c75;
  --brand-secondary: #1b6ca8;
  --brand-accent: #00b4d8;
  --brand-accent-light: #90e0ef;
  --brand-gold: #f4a261;

  /* Light Mode */
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #0f4c75;
  --bg-sidebar-hover: #1b6ca8;
  --bg-topbar: #ffffff;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --text-sidebar: rgba(255,255,255,0.85);
  --text-sidebar-active: #ffffff;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --input-bg: #ffffff;
  --input-border: #cbd5e0;
  --input-focus: #00b4d8;

  /* Status Colors */
  --success: #38a169;
  --success-light: #c6f6d5;
  --warning: #d69e2e;
  --warning-light: #fefcbf;
  --danger: #e53e3e;
  --danger-light: #fed7d7;
  --info: #3182ce;
  --info-light: #bee3f8;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2333;
  --bg-sidebar: #0a0f18;
  --bg-sidebar-hover: #1b2535;
  --bg-topbar: #161b22;
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --border-color: #2d3748;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
  --input-bg: #2d3748;
  --input-border: #4a5568;
  --success-light: rgba(56,161,105,0.15);
  --warning-light: rgba(214,158,46,0.15);
  --danger-light: rgba(229,62,62,0.15);
  --info-light: rgba(49,130,206,0.15);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}
p { color: var(--text-secondary); }
a { color: var(--brand-accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--brand-secondary); }

/* ─── Layout Shell ───────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 1000;
  transition: var(--transition-slow);
  overflow: hidden;
  box-shadow: 4px 0 20px rgba(0,0,0,0.2);
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--topbar-height);
  text-decoration: none;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
}

.sidebar-logo-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.sidebar-title {
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
  overflow: hidden;
  transition: var(--transition);
}
.sidebar-title small {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  color: rgba(255,255,255,0.55);
  margin-top: 1px;
}

.sidebar.collapsed .sidebar-title { width: 0; opacity: 0; }

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

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 16px 18px 6px;
  transition: var(--transition);
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: var(--transition);
  border-radius: 0;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  margin: 2px 8px;
  border-radius: 8px;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: white;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-secondary));
  color: white;
  box-shadow: 0 4px 12px rgba(0,180,216,0.35);
}

.nav-item .nav-icon {
  font-size: 1.1rem;
  width: 24px;
  flex-shrink: 0;
  text-align: center;
}

.nav-item .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition);
}
.sidebar.collapsed .nav-label { width: 0; opacity: 0; }

.nav-item .nav-badge {
  background: var(--brand-gold);
  color: #1a202c;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  transition: var(--transition);
}
.sidebar.collapsed .nav-badge { opacity: 0; }

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

/* ─── Main Content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition-slow);
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* ─── Top Bar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: background 0.3s;
}

.topbar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.topbar-toggle:hover { background: var(--bg-primary); color: var(--text-primary); }

.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px 8px 40px;
  border-radius: 24px;
  font-size: 0.875rem;
  transition: var(--transition);
  font-family: var(--font);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(0,180,216,0.15);
}

.topbar-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1100;
  display: none;
}
.search-results-dropdown.show { display: block; }
.search-result-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
  font-size: 0.875rem;
}
.search-result-item:hover { background: var(--bg-primary); }
.search-result-item .result-icon { color: var(--brand-accent); font-size: 0.9rem; }
.search-result-item .result-text strong { display: block; color: var(--text-primary); }
.search-result-item .result-text span { color: var(--text-muted); font-size: 0.8rem; }

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  transition: var(--transition);
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-btn:hover { background: var(--bg-primary); color: var(--text-primary); }

.topbar-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: 2px solid var(--border-color);
  transition: var(--transition);
  flex-shrink: 0;
}
.user-avatar:hover { border-color: var(--brand-accent); }

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 1100;
  display: none;
  overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}
.user-dropdown-header .name { font-weight: 600; font-size: 0.9rem; }
.user-dropdown-header .role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
  margin-top: 2px;
}
.dropdown-item-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  transition: var(--transition);
  font-family: var(--font);
  text-align: left;
}
.dropdown-item-btn:hover { background: var(--bg-primary); color: var(--text-primary); }
.dropdown-item-btn.danger:hover { background: var(--danger-light); color: var(--danger); }

/* ─── Page Content ───────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

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

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}

/* ─── Stat Cards ─────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  overflow: hidden;
  position: relative;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--brand-accent));
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

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

.stat-info { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}
.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
}
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* Stat card color variants */
.stat-card.primary { --card-accent: var(--brand-primary); }
.stat-card.primary .stat-icon { background: rgba(15,76,117,0.1); color: var(--brand-primary); }
.stat-card.accent { --card-accent: var(--brand-accent); }
.stat-card.accent .stat-icon { background: rgba(0,180,216,0.1); color: var(--brand-accent); }
.stat-card.success { --card-accent: var(--success); }
.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.warning { --card-accent: var(--warning); }
.stat-card.warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.danger { --card-accent: var(--danger); }
.stat-card.danger .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-card.info { --card-accent: var(--info); }
.stat-card.info .stat-icon { background: var(--info-light); color: var(--info); }
.stat-card.gold { --card-accent: var(--brand-gold); }
.stat-card.gold .stat-icon { background: rgba(244,162,97,0.15); color: var(--brand-gold); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: white;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(15,76,117,0.3);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(15,76,117,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-accent {
  background: linear-gradient(135deg, var(--brand-accent), #0096c7);
  color: white;
  border-color: var(--brand-accent);
  box-shadow: 0 2px 8px rgba(0,180,216,0.3);
}
.btn-accent:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(0,180,216,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, #38a169, #2f855a);
  color: white;
  border-color: var(--success);
  box-shadow: 0 2px 8px rgba(56,161,105,0.3);
}
.btn-success:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(56,161,105,0.4); transform: translateY(-1px); color: white; }

.btn-danger {
  background: linear-gradient(135deg, #e53e3e, #c53030);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(229,62,62,0.3); transform: translateY(-1px); color: white; }

.btn-warning {
  background: linear-gradient(135deg, #d69e2e, #b7791f);
  color: white;
  border-color: var(--warning);
}
.btn-warning:hover:not(:disabled) { color: white; }

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-primary); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font);
  transition: var(--transition);
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(0,180,216,0.15);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid { border-color: var(--success); }

.invalid-feedback { color: var(--danger); font-size: 0.78rem; margin-top: 4px; }
.form-text { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; }

.input-group {
  position: relative;
  display: flex;
}
.input-group .form-control { border-radius: 0; }
.input-group :first-child { border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm); }
.input-group :last-child { border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0; }

.input-icon-group { position: relative; }
.input-icon-group .form-control { padding-left: 38px; }
.input-icon-group .form-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  text-align: left;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: var(--transition);
}

.table tbody tr:hover {
  background: var(--bg-primary);
}

.table-striped tbody tr:nth-child(even) {
  background: rgba(0,0,0,0.02);
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-primary { background: rgba(15,76,117,0.1); color: var(--brand-primary); }
.badge-accent { background: rgba(0,180,216,0.12); color: var(--brand-accent); }
.badge-muted { background: var(--bg-primary); color: var(--text-muted); border: 1px solid var(--border-color); }

/* ─── Attendance Status Badges ───────────────────────────────────────────── */
.att-present { background: var(--success-light); color: var(--success); }
.att-absent { background: var(--danger-light); color: var(--danger); }
.att-late { background: var(--warning-light); color: var(--warning); }
.att-halfday { background: var(--info-light); color: var(--info); }

/* ─── Attendance Grid ────────────────────────────────────────────────────── */
.attendance-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.attendance-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 0;
  background: var(--bg-card);
  padding: 12px 16px;
  transition: var(--transition);
  gap: 12px;
}

.attendance-row:hover { background: var(--bg-primary); }

.attendance-row .student-roll {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
}

.attendance-row .student-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.att-buttons {
  display: flex;
  gap: 4px;
}

.att-btn {
  padding: 5px 10px;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  color: var(--text-secondary);
}

.att-btn:hover { border-color: var(--brand-accent); }
.att-btn.active-present { background: var(--success-light); border-color: var(--success); color: var(--success); }
.att-btn.active-absent { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.att-btn.active-late { background: var(--warning-light); border-color: var(--warning); color: var(--warning); }
.att-btn.active-halfday { background: var(--info-light); border-color: var(--info); color: var(--info); }

/* ─── Login Page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #0a1628 0%, #0f4c75 50%, #1b6ca8 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 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='none' fill-rule='evenodd'%3E%3Cg fill='%2300b4d8' fill-opacity='0.04'%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/g%3E%3C/svg%3E");
}

.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
}

.login-school-logo {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  object-fit: cover;
  margin-bottom: 24px;
  border: 3px solid rgba(255,255,255,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-school-logo-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 900;
  color: white;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(0,180,216,0.4);
}

.login-school-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
  text-align: center;
  line-height: 1.3;
  max-width: 300px;
}

.login-school-tagline {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  margin-top: 8px;
  text-align: center;
}

.login-features {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 300px;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.8);
  font-size: 0.875rem;
}

.login-feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.login-right {
  width: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--bg-card);
  position: relative;
}

.login-form-card {
  width: 100%;
  max-width: 360px;
}

.login-form-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-form-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 32px;
}

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(20px);
  transition: var(--transition-slow);
}

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

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

.modal-title { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-primary); color: var(--text-primary); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── Toast Notifications ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.toast.show { transform: translateX(0); }

.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--toast-color, var(--brand-accent));
}

.toast-icon {
  font-size: 1.1rem;
  margin-top: 2px;
  color: var(--toast-color, var(--brand-accent));
}

.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); }
.toast-message { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px;
  margin-top: 2px;
}

.toast.success { --toast-color: var(--success); }
.toast.error { --toast-color: var(--danger); }
.toast.warning { --toast-color: var(--warning); }
.toast.info { --toast-color: var(--info); }

/* ─── Loading Skeletons ──────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--border-color) 25%,
    var(--bg-primary) 50%,
    var(--border-color) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: 6px;
}

@keyframes skeleton-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 20px;
}

/* ─── Charts Wrapper ─────────────────────────────────────────────────────── */
.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 200px;
}

/* ─── Status Indicators ──────────────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 0 2px var(--success-light); }
.status-dot.offline { background: var(--danger); }
.status-dot.warning { background: var(--warning); }

/* ─── Activity Feed ──────────────────────────────────────────────────────── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

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

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

.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 0.875rem; color: var(--text-primary); font-weight: 500; }
.activity-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 8px; }
.empty-state p { font-size: 0.875rem; }

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-accent { color: var(--brand-accent) !important; }

.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }

.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

.rounded { border-radius: var(--border-radius); }
.rounded-sm { border-radius: var(--border-radius-sm); }
.rounded-lg { border-radius: var(--border-radius-lg); }

.divider { height: 1px; background: var(--border-color); margin: 16px 0; }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(var(--bg-card), 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: inherit;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in { animation: fadeIn 0.3s ease forwards; }
.animate-slide-in { animation: slideIn 0.3s ease forwards; }

/* Staggered children */
.stagger > * { opacity: 0; animation: fadeIn 0.3s ease forwards; }
.stagger > *:nth-child(1) { animation-delay: 0.0s; }
.stagger > *:nth-child(2) { animation-delay: 0.05s; }
.stagger > *:nth-child(3) { animation-delay: 0.10s; }
.stagger > *:nth-child(4) { animation-delay: 0.15s; }
.stagger > *:nth-child(5) { animation-delay: 0.20s; }
.stagger > *:nth-child(6) { animation-delay: 0.25s; }
.stagger > *:nth-child(7) { animation-delay: 0.30s; }
.stagger > *:nth-child(8) { animation-delay: 0.35s; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
  }
  .sidebar-overlay.show { display: block; }
}

@media (max-width: 768px) {
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar-search { display: none; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 32px 24px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .page-header { flex-direction: column; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; max-width: 100%; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

/* ─── Print ──────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-actions, .toast-container { display: none !important; }
  .main-content { margin: 0 !important; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
