/*
  styles.css
  Tailwind's Play CDN only compiles utility classes it finds directly in the
  DOM — it does NOT process @apply inside a linked stylesheet. So the
  reusable component classes below (buttons, modals, form fields, nav links)
  are written in plain CSS, using the same color/spacing values as our
  Tailwind config, rather than @apply. This keeps index.html's markup clean
  (e.g. class="btn-primary" instead of a wall of utilities) while staying
  100% compatible with the CDN setup.
*/

/* ---------- Focus ring (accessibility: never remove outlines, only restyle) ---------- */
:focus-visible {
  outline: 2px solid #6366F1;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Sidebar nav links ---------- */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569; /* slate-600 */
  transition: background-color 0.15s ease, color 0.15s ease;
  text-align: left;
}
.nav-link:hover { background-color: #F1F5F9; color: #1E293B; }
.dark .nav-link { color: #94A3B8; }
.dark .nav-link:hover { background-color: rgba(255,255,255,0.05); color: #F1F5F9; }
.nav-link-active {
  background-color: #EEF2FF;
  color: #4338CA;
}
.nav-link-active:hover { background-color: #EEF2FF; color: #4338CA; }
.dark .nav-link-active { background-color: rgba(99,102,241,0.15); color: #A5B4FC; }
.dark .nav-link-active:hover { background-color: rgba(99,102,241,0.15); color: #A5B4FC; }

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  background-color: #4F46E5; color: white; font-size: 0.875rem; font-weight: 500;
  padding: 0.5rem 1rem; border-radius: 0.5rem; transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background-color: #4338CA; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  background-color: white; color: #334155; font-size: 0.875rem; font-weight: 500;
  padding: 0.5rem 1rem; border-radius: 0.5rem; border: 1px solid #E2E8F0;
  transition: background-color 0.15s ease;
}
.btn-secondary:hover { background-color: #F8FAFC; }
.dark .btn-secondary { background-color: #1E293B; color: #E2E8F0; border-color: #334155; }
.dark .btn-secondary:hover { background-color: #293548; }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  background-color: #E11D48; color: white; font-size: 0.875rem; font-weight: 500;
  padding: 0.5rem 1rem; border-radius: 0.5rem; transition: background-color 0.15s ease;
}
.btn-danger:hover { background-color: #BE123C; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 0.5rem; color: #64748B;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.btn-icon:hover { background-color: #F1F5F9; color: #1E293B; }
.dark .btn-icon { color: #94A3B8; }
.dark .btn-icon:hover { background-color: rgba(255,255,255,0.06); color: #F1F5F9; }

/* ---------- Form fields ---------- */
.form-label {
  display: block; font-size: 0.8125rem; font-weight: 500; color: #475569;
  margin-bottom: 0.375rem;
}
.dark .form-label { color: #CBD5E1; }

.form-input {
  width: 100%; font-size: 0.875rem; padding: 0.5rem 0.75rem;
  border-radius: 0.5rem; border: 1px solid #E2E8F0; background-color: #FFFFFF;
  color: inherit; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus {
  outline: none; border-color: #6366F1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-input.input-error { border-color: #E11D48; }
.form-input.input-error:focus { box-shadow: 0 0 0 3px rgba(225,29,72,0.15); }
.dark .form-input { background-color: #0F172A; border-color: #334155; }

.form-error {
  font-size: 0.75rem; color: #E11D48; margin-top: 0.25rem; min-height: 1rem;
}

.status-radio {
  display: flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem;
  padding: 0.5rem 0.75rem; border-radius: 0.5rem; border: 1px solid #E2E8F0;
  cursor: pointer; flex: 1;
}
.dark .status-radio { border-color: #334155; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center;
  justify-content: center; background-color: rgba(15,23,42,0.5);
  padding: 1rem; animation: fade-in 0.15s ease-out;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal-panel {
  background-color: white; border-radius: 1rem; width: 100%;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  animation: scale-in 0.15s ease-out;
}
.dark .modal-panel { background-color: #0F172A; border: 1px solid #1E293B; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid #E2E8F0; flex-shrink: 0;
}
.dark .modal-header { border-color: #1E293B; }

.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1.125rem 1.5rem; border-top: 1px solid #E2E8F0;
}
.dark .modal-footer { border-color: #1E293B; }

.modal-close {
  width: 2rem; height: 2rem; border-radius: 0.5rem; color: #94A3B8;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.15s ease;
}
.modal-close:hover { background-color: #F1F5F9; color: #475569; }
.dark .modal-close:hover { background-color: rgba(255,255,255,0.06); }

/* ---------- Detail modal tabs ---------- */
.detail-tab {
  padding: 0.625rem 0.25rem; margin-right: 1.5rem; font-size: 0.875rem;
  font-weight: 500; color: #94A3B8; border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.detail-tab:hover { color: #475569; }
.detail-tab-active { color: #4F46E5; border-color: #4F46E5; }
.dark .detail-tab-active { color: #A5B4FC; border-color: #A5B4FC; }

/* ---------- Stat cards ---------- */
.stat-card {
  background-color: white; border-radius: 0.875rem; padding: 1.25rem;
  border: 1px solid #E2E8F0; transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05); transform: translateY(-1px); }
.dark .stat-card { background-color: #111827; border-color: #1E293B; }

/* ---------- Data table ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; color: #94A3B8; padding: 0.75rem 1rem; border-bottom: 1px solid #E2E8F0;
}
.dark .data-table th { border-color: #1E293B; }
.data-table td { padding: 0.875rem 1rem; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
.dark .data-table td { border-color: #1E293B; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background-color 0.15s ease; }
.data-table tbody tr:hover { background-color: #F8FAFC; }
.dark .data-table tbody tr:hover { background-color: rgba(255,255,255,0.02); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem;
  font-weight: 500; padding: 0.2rem 0.55rem; border-radius: 9999px;
}
.badge-dot { width: 0.375rem; height: 0.375rem; border-radius: 9999px; }

.badge-active { background-color: #ECFDF5; color: #047857; }
.badge-active .badge-dot { background-color: #10B981; }
.dark .badge-active { background-color: rgba(16,185,129,0.12); color: #34D399; }

.badge-inactive { background-color: #F1F5F9; color: #64748B; }
.badge-inactive .badge-dot { background-color: #94A3B8; }
.dark .badge-inactive { background-color: rgba(148,163,184,0.12); color: #94A3B8; }

.badge-present { background-color: #ECFDF5; color: #047857; }
.badge-absent { background-color: #FFF1F2; color: #BE123C; }
.badge-late { background-color: #FFFBEB; color: #B45309; }
.badge-excused { background-color: #F0F9FF; color: #0369A1; }
.dark .badge-present { background-color: rgba(16,185,129,0.12); color: #34D399; }
.dark .badge-absent { background-color: rgba(244,63,94,0.12); color: #FB7185; }
.dark .badge-late { background-color: rgba(245,158,11,0.12); color: #FBBF24; }
.dark .badge-excused { background-color: rgba(14,165,233,0.12); color: #38BDF8; }

/* ---------- GPA gauge ring (signature element) ---------- */
.gpa-ring-track { stroke: #F1F5F9; }
.dark .gpa-ring-track { stroke: #1E293B; }
.gpa-ring-excellent { stroke: #10B981; }
.gpa-ring-good { stroke: #6366F1; }
.gpa-ring-average { stroke: #F59E0B; }
.gpa-ring-at-risk { stroke: #F43F5E; }
.gpa-ring-none { stroke: #CBD5E1; }

/* ---------- Attendance heatmap cells ---------- */
.heat-cell { width: 100%; aspect-ratio: 1; border-radius: 0.3rem; }
.heat-cell-present { background-color: #10B981; }
.heat-cell-late { background-color: #F59E0B; }
.heat-cell-absent { background-color: #F43F5E; }
.heat-cell-excused { background-color: #38BDF8; }
.heat-cell-none { background-color: #F1F5F9; }
.dark .heat-cell-none { background-color: #1E293B; }

/* ---------- Attendance marking pills ---------- */
.attendance-pill {
  font-size: 0.75rem; font-weight: 500; padding: 0.35rem 0.65rem;
  border-radius: 9999px; border: 1px solid #E2E8F0; color: #475569;
  transition: all 0.15s ease; white-space: nowrap;
}
.attendance-pill:hover { border-color: #A5B4FC; }
.dark .attendance-pill { border-color: #334155; color: #CBD5E1; }
.dark .attendance-pill:hover { border-color: #6366F1; }

.attendance-pill-active-present { background-color: #10B981; border-color: #10B981; color: white; opacity: 1 !important; }
.attendance-pill-active-late { background-color: #F59E0B; border-color: #F59E0B; color: white; opacity: 1 !important; }
.attendance-pill-active-absent { background-color: #F43F5E; border-color: #F43F5E; color: white; opacity: 1 !important; }
.attendance-pill-active-excused { background-color: #38BDF8; border-color: #38BDF8; color: white; opacity: 1 !important; }

/* ---------- Empty states ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 3.5rem 1.5rem;
}

/* ---------- Skeleton loading ---------- */
.skeleton {
  background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 37%, #F1F5F9 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 0.5rem;
}
.dark .skeleton {
  background: linear-gradient(90deg, #1E293B 25%, #293548 37%, #1E293B 63%);
  background-size: 400% 100%;
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------- Scrollbar (subtle, not default-ugly) ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: #CBD5E1; border-radius: 9999px; }
.dark ::-webkit-scrollbar-thumb { background-color: #334155; }