/* ============================================================
   School OS — component library
   ============================================================ */

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.card-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--shadow-sm); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803D; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }

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

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field-error {
  border-color: var(--danger) !important;
}
.field-hint { font-size: 12px; color: var(--text-subtle); }
.field-hint.is-error { color: var(--danger); }

.search-input { position: relative; }

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td {
  text-align: right;
  padding: 14px 18px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.table th {
  background: var(--surface-hover);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform var(--transition);
}
.modal-overlay.is-open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; bottom: 24px; left: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  min-width: 220px;
  display: flex; align-items: center; gap: 10px;
  transform: translateY(10px);
  opacity: 0;
  animation: toast-in var(--transition) forwards;
}
.toast.toast-success { background: var(--success); }
.toast.toast-danger { background: var(--danger); }
@keyframes toast-in {
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-primary { background: var(--primary-light); color: var(--primary-hover); }
.badge-success { background: var(--success-light); color: #15803D; }
.badge-danger { background: var(--danger-light); color: #B91C1C; }
.badge-warning { background: var(--warning-light); color: #B45309; }
.badge-info { background: var(--info-light); color: #0E7490; }
.badge-neutral { background: var(--surface-hover); color: var(--text-muted); }

/* attendance-specific aliases */
.badge-present { background: var(--success-light); color: #15803D; }
.badge-absent { background: var(--danger-light); color: #B91C1C; }
.badge-late { background: var(--warning-light); color: #B45309; }
.badge-excused { background: var(--info-light); color: #0E7490; }

/* ---------- Progress bar ---------- */
.progress { background: var(--surface-hover); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: 999px;
  background: var(--primary);
  transition: width var(--transition);
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* ---------- Avatar ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-hover);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; color: var(--text-subtle); }
.empty-state-title { font-weight: 700; color: var(--text); margin-bottom: 6px; }

/* ---------- Skeleton loading ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--border) 37%, var(--surface-hover) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------- Sidebar / shell ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 24px;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-link:hover { background: var(--sidebar-bg-hover); color: #fff; text-decoration: none; }
.sidebar-link.is-active { background: var(--sidebar-active-bg); color: #fff; }
.sidebar-link svg { flex-shrink: 0; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px; margin-top: 14px; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-icon-btn {
  position: relative;
  background: none; border: none; cursor: pointer;
  padding: 8px; border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar-icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.topbar-icon-btn .dot {
  position: absolute; top: 6px; left: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* ---------- Notification dropdown ---------- */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 10px); left: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 30;
  display: none;
}
.dropdown.is-open .dropdown-panel { display: block; }
.dropdown-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item-title { font-weight: 700; margin-bottom: 2px; }
.dropdown-item.is-unread { background: var(--primary-light); }

/* ---------- Stat card ---------- */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .stat-card, .id-card { animation: none !important; }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition), transform var(--transition);
  animation: fade-in-up 0.35s ease both;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary-hover);
  flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* ---------- Student identity card: glass card + floating stat badges ---------- */
@keyframes id-float-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.id-chip-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.id-chip-value { font-size: 13px; font-weight: 700; color: var(--text); }

.id-hero {
  position: relative;
  padding: 28px 100px 56px;
  margin-bottom: 24px;
  min-height: 300px;
  background:
    radial-gradient(circle at 22% 15%, rgba(124, 58, 237, 0.18), transparent 55%),
    radial-gradient(circle at 82% 85%, rgba(236, 72, 153, 0.16), transparent 55%),
    radial-gradient(circle at 85% 15%, rgba(8, 145, 178, 0.1), transparent 50%);
  border-radius: var(--radius-lg);
}
.id-glass-card {
  position: relative;
  z-index: 2;
  max-width: 380px;
  margin: 0 auto;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.62));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  transform: rotate(-2deg);
  transition: transform var(--transition);
  animation: fade-in-up 0.5s ease both;
}
.id-glass-card:hover { transform: rotate(0deg); }
.id-glass-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  font-size: 13px;
  color: var(--text);
}
.id-glass-row:last-child { border-bottom: none; }
.id-glass-row svg { color: var(--primary); flex-shrink: 0; }

.id-float-badge {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  animation: fade-in-up 0.5s ease both, id-float-bob 4.5s ease-in-out infinite;
}
.id-float-icon {
  position: relative;
  overflow: hidden;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 0 -3px 6px rgba(0, 0, 0, 0.15), 0 3px 8px rgba(0, 0, 0, 0.18);
}
/* A soft diagonal highlight over the gradient, like light hitting glossy
   plastic — pure CSS, no image assets. */
.id-float-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 55%);
}
.id-float-tl .id-float-icon { background: linear-gradient(145deg, #a78bfa, var(--primary)); }
.id-float-tr .id-float-icon { background: linear-gradient(145deg, #4ade80, var(--success)); }
.id-float-bl .id-float-icon { background: linear-gradient(145deg, #fbbf24, var(--warning)); }
.id-float-br .id-float-icon { background: linear-gradient(145deg, #22d3ee, var(--info)); }
.id-float-tl { top: 8px; left: 8px; }
.id-float-tr { top: 8px; right: 8px; }
.id-float-bl { bottom: 8px; left: 24px; }
.id-float-br { bottom: 8px; right: 24px; }

@media (max-width: 720px) {
  .id-hero { padding: 20px; min-height: auto; display: flex; flex-direction: column; gap: 12px; }
  .id-glass-card { max-width: none; transform: none; }
  .id-glass-card:hover { transform: none; }
  .id-float-badge { position: static; animation: fade-in-up 0.5s ease both; }
}
@media (prefers-reduced-motion: reduce) {
  .id-glass-card, .id-float-badge { animation: none !important; }
}

/* ---------- Student cards grid ---------- */
.student-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.student-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  animation: fade-in-up 0.4s ease both;
}
.student-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.student-card:nth-child(5n+1) { border-top-color: var(--primary); }
.student-card:nth-child(5n+2) { border-top-color: var(--success); }
.student-card:nth-child(5n+3) { border-top-color: var(--info); }
.student-card:nth-child(5n+4) { border-top-color: var(--warning); }
.student-card:nth-child(5n+5) { border-top-color: var(--danger); }
.student-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.student-card-avatar { width: 44px; height: 44px; font-size: 15px; }
.student-card-name { font-size: 15px; margin-bottom: 4px; }
.student-card-meta { font-size: 13px; color: var(--text-muted); margin: 0 0 2px; }
.student-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
@media (prefers-reduced-motion: reduce) {
  .student-card { animation: none !important; }
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 12px 18px;
  font-weight: 600; font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.is-active { color: var(--primary); border-color: var(--primary); }

/* ---------- Mobile bottom nav ---------- */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; right: 0; left: 0;
  background: var(--sidebar-bg);
  padding: 8px 4px;
  z-index: 40;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.bottom-nav-inner { display: flex; justify-content: space-around; }
.bottom-nav-link {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--sidebar-text);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.bottom-nav-link.is-active { color: #fff; }
.bottom-nav-link:hover { text-decoration: none; color: #fff; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .bottom-nav { display: block; }
}

/* ---------- Auth page ---------- */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--sidebar-bg) 0%, #1e293b 100%);
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}
.auth-logo {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px;
  margin: 0 auto 18px;
}
.auth-title { text-align: center; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.auth-error {
  background: var(--danger-light);
  color: #B91C1C;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.auth-error.is-visible { display: block; }
