/* QR-Guard - shared styles. Mobile-first, clean, professional. */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* AUK Brand - change these to retheme the entire app */
  --primary: #9a182b;
  --primary-hover: #7d1323;
  --primary-light: #fcedef;
  --accent: #D4A037;
  --accent-hover: #c09030;
  --accent-light: #fdf6e8;

  /* Semantic colors */
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;

  /* Surfaces */
  --bg: #f4ecdb;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #dfe4eb;

  /* Shape */
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  animation: fadeIn 0.3s ease;
}

/* ═══════════════════════════════════════════════════
   GLOBAL INTERACTIVITY BASELINE
   Inspired by StratOS - every element feels alive
   ═══════════════════════════════════════════════════ */

/* Page entrance */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* All interactive elements get smooth transitions */
a { transition: color 0.15s ease, opacity 0.15s ease; }
input, select, textarea { transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease; }
select { cursor: pointer; }
select:hover { border-color: var(--text-muted); }

/* Custom scrollbar - accent-tinted, thin */
* { scrollbar-width: thin; scrollbar-color: rgba(154,24,43,0.25) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(154,24,43,0.25); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(154,24,43,0.45); }

/* --- Auth pages: centered layout --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 1rem 4rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 50%, var(--accent-light) 100%);
}

.auth-brand {
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-brand h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.auth-brand .brand-accent {
  color: var(--accent);
}

.auth-brand p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.4s ease;
  overflow: hidden;
}

.auth-footer {
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* --- General layout --- */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.container-wide {
  max-width: 1024px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
}

h1 { font-size: clamp(1.25rem, 4vw, 1.5rem); font-weight: 700; margin-bottom: 1.5rem; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.05rem, 3vw, 1.2rem); font-weight: 600; margin-bottom: 0.75rem; overflow-wrap: anywhere; }

/* --- Cards --- */
.card {
  background: var(--surface);
  border: none;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  animation: slideUp 0.35s ease backwards;
}

.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card:nth-child(4) { animation-delay: 0.18s; }
.card:nth-child(5) { animation-delay: 0.24s; }

.card:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  transform: translateY(-2px);
}

.card-clickable {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.card-clickable:hover {
  box-shadow: 0 6px 20px rgba(154,24,43,0.1), 0 0 0 2px var(--primary-light);
}

/* Course card - stacked layout for mobile */
.course-card {
  position: relative;
  padding: 1.5rem;
  padding-left: 1.75rem;
}

.course-card h2 { margin-bottom: 0.15rem; }

.course-card-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.course-card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.course-card-pct {
  text-align: center;
  min-width: 50px;
}

.course-card-pct-value {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.course-card-pct-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1rem;
  min-width: 0; /* lets the group shrink inside grid/flex parents */
}

/* Fluid 2-col form grid. Each column gets at least min(180px, 100%) so the
   grid collapses to one column on narrow viewports without needing a media
   query. */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 0.75rem;
}

/* Search bar above the geofence map - input + button. Wraps when there
   isn't enough room. */
.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.search-row > input { flex: 1 1 200px; min-width: 0; }

/* Weekly schedule slot row. Day select + start + 'to' + end + remove.
   Wraps cleanly on narrow screens; selects expand to fill available
   space rather than competing for fixed flex ratios. */
.schedule-slot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.schedule-slot-row .slot-day { flex: 2 1 8rem; min-width: 0; }
.schedule-slot-row .slot-time { flex: 1 1 5rem; min-width: 0; }
.schedule-slot-row .slot-to { color: var(--text-muted); }
.schedule-slot-row .slot-remove {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 1.25rem; padding: 0 0.25rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--text);
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(154,24,43,0.35);
}

input::placeholder { color: #94a3b8; }

/* --- Buttons --- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: filter 150ms ease, transform 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

button:hover:not(.password-toggle), .btn:hover {
  filter: brightness(1.1);
}

button:active:not(.password-toggle), .btn:active {
  filter: brightness(0.92);
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(154,24,43,0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(154,24,43,0.25);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 2px 4px rgba(220,38,38,0.2);
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.05rem;
}

/* --- Messages / Alerts --- */
.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.message.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.message.success {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

/* --- Nav --- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: url('/assets/campus-bg.jpg') center/cover no-repeat;
  position: relative;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(90,12,22,0.92);
  z-index: 0;
}

.nav > * {
  position: relative;
  z-index: 1;
}

.nav-brand {
  font-weight: 700;
  font-size: clamp(1.05rem, 3.5vw, 1.3rem);
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: Georgia, 'Times New Roman', serif;
}

.nav-brand img {
  height: clamp(32px, 7vw, 44px);
  width: auto;
  aspect-ratio: 180 / 200;
}

.nav-left {
  display: flex;
  align-items: center;
}

.nav-user {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.7);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0.03em;
}

/* --- Bottom navigation bar --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 600;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Reserve room at the bottom of every page for the fixed bottom-nav AND
   any home-bar safe area (iPhone X+, Android 3-button gesture bar).
   Without the env() addition, content collides with the nav on devices
   that have a non-zero safe-area-inset-bottom. */
body.has-bottom-nav {
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.has-bottom-nav .container-wide {
  flex: 1;
}

/* Legacy nav-links for simple pages */
.nav-links { display: flex; gap: 1.25rem; align-items: center; margin-left: 1rem; }
.nav-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s;
}
.nav-links a:hover {
  background: var(--surface);
  border-color: var(--text-muted);
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Enrollment code display --- */
.enrollment-code {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent-hover);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.12em;
  border: 1px solid var(--accent);
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* --- Utilities --- */
.text-muted { color: var(--text-muted); font-size: 0.875rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* --- Map --- */
#map {
  height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-sm);
}

/* --- Password toggle --- */
.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 2.5rem;
}

.password-toggle {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  transition: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.password-toggle:hover {
  color: var(--text);
}

.password-toggle:active {
  transform: translateY(-50%);
}

/* --- Loading states --- */
.btn.loading {
  pointer-events: none;
  opacity: 0.75;
  position: relative;
}

.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  margin-left: 0.4rem;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  z-index: 9999;
  animation: loading-bar 1.5s ease-in-out infinite;
  transform-origin: left;
}

@keyframes loading-bar {
  0% { transform: scaleX(0); }
  50% { transform: scaleX(0.7); }
  100% { transform: scaleX(1); opacity: 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
}

.skeleton-card .skeleton { opacity: 0.6; }
.skeleton-title { height: 1.25rem; width: 60%; }
.skeleton-text { height: 0.875rem; width: 40%; }

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

/* Footer removed - campus image used as nav background */

/* Screen-reader-only text: keeps the label in the accessibility tree
   without taking visible space. Used for inputs that have visible
   context but no visible <label>. */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Respect user motion preferences. Without this the slideUp / pulse /
   staggered card animations run even for users who request reduced
   motion (WCAG 2.3.3). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Prevent horizontal overflow on all devices --- */
html, body {
  overflow-x: hidden;
  width: 100%;
}

.card {
  overflow-x: auto;
}

/* --- Mobile responsive --- */
@media (max-width: 640px) {
  .container-wide { padding: 0.75rem; width: 100%; }
  .nav { padding: 0.6rem 1rem; }
  .auth-card { padding: 1.5rem; margin: 0 0.5rem; }
  table { font-size: 0.75rem; display: block; overflow-x: auto; }
  #scheduleSlots > div { flex-wrap: wrap; }
  #scheduleSlots select { min-width: 0; font-size: 0.85rem; }
  th, td { padding: 0.35rem 0.4rem; }
  input[type="datetime-local"] { font-size: 0.85rem; }
}

/* --- Auth card header banner --- */
.auth-card-header {
  text-align: center;
  background: url('/assets/campus-bg.jpg') center/cover no-repeat;
  color: #fff;
  margin: -2rem -2rem 1.5rem;
  padding: 1.5rem 2rem;
  border-radius: 12px 12px 0 0;
  position: relative;
  overflow: hidden;
}

.auth-card-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(154,24,43,0.75) 0%, rgba(100,14,28,0.82) 100%);
  z-index: 0;
}

.auth-card-header > * {
  position: relative;
  z-index: 1;
}

.auth-card-header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.auth-card-header p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
}

/* --- Page header (flat section title with optional badge) --- */
.page-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.page-header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* --- Count badge (red pill with number) --- */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0;
}

/* --- Floating action button --- */
.fab {
  position: fixed;
  right: 1.25rem;
  bottom: calc(70px + 1rem + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  font-weight: 300;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(154, 24, 43, 0.35), 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 90;
}

.fab:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(154, 24, 43, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fab:active {
  transform: scale(0.95);
}

body:not(.has-bottom-nav) .fab {
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

/* AUK brand accent: a thin gradient on the top of every card.
   Uniform across courses to avoid the "color-coded per item" look. */
.course-card::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 65%, var(--accent) 100%);
  border-radius: 14px 14px 0 0;
}

/* --- Course detail hero --- */
.course-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #6f0f1f 100%);
  color: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 4px 12px rgba(154, 24, 43, 0.2);
}

.course-hero-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}
.course-hero-actions .btn-danger {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  box-shadow: none;
}
.course-hero-actions .btn-danger:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Status pill inside the crimson session-detail hero. Same semantic palette
   as elsewhere, lifted by white text so it stays legible. */
.session-status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 0.9rem;
  margin-bottom: 0.4rem;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}
.session-status-badge.status-scheduled { background: rgba(212, 160, 55, 0.55); }
.session-status-badge.status-active    { background: rgba(22, 163, 74, 0.7); }
.session-status-badge.status-closed    { background: rgba(255, 255, 255, 0.18); }
.session-status-badge.status-cancelled { background: rgba(220, 38, 38, 0.7); }

/* Session-detail roster: stacked rows, each row breaks into label/value
   pairs that wrap fluidly on narrow viewports. */
.roster-list { margin-top: 0.5rem; }

.roster-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.5rem;
  min-width: 0;
}

.roster-row .roster-name {
  flex: 1 1 12rem;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.roster-row .roster-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.roster-row .roster-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.roster-status-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.roster-status-pill.status-present { background: var(--success-light); color: var(--success); }
.roster-status-pill.status-absent  { background: var(--danger-light);  color: var(--danger); }
.roster-status-pill.status-excused { background: var(--warning-light); color: var(--warning); }

.roster-override-btn {
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.roster-check {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  cursor: pointer;
  margin: 0;
}

/* Sticky bulk-actions bar above the roster. Only visible when >=1 student
   is checked; collapses to a single row on narrow viewports. */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem 0.85rem;
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 5;
}
.bulk-bar select { width: auto; }

/* Session notes card under the roster on the session-detail page. */
.notes-card {
  background: var(--surface);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin-top: 0.5rem;
}
.notes-card textarea {
  resize: vertical;
  min-height: 4rem;
  font-family: inherit;
}
.notes-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.notes-status {
  flex: 1;
  font-size: 0.8rem;
}

/* Small note icon inline on the course-detail session row when notes
   exist on that session. Pure visual hint that there is context to read. */
.session-notes-icon {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  margin-left: 0.4rem;
  font-style: normal;
  color: var(--accent);
  font-size: 0.9em;
  vertical-align: -2px;
}
.session-notes-icon::before { content: '\270e'; } /* lower-right pencil */

/* Rejected-scans collapsible section. Uses native <details>/<summary> so
   keyboard + assistive tech support is free. */
.rejected-section {
  margin-top: 1.5rem;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 0;
}
.rejected-section > summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  list-style: none;
}
.rejected-section > summary::-webkit-details-marker { display: none; }
.rejected-section > summary::before {
  content: '+';
  display: inline-block;
  width: 1.1em;
  font-weight: 700;
  color: var(--text-muted);
}
.rejected-section[open] > summary::before { content: '-'; }

.rejected-group {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
}
.rejected-group-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.rejected-count {
  display: inline-block;
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-right: 0.5rem;
}
.rejected-item {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.15rem 0 0.15rem 1.6rem;
  flex-wrap: wrap;
}
.rejected-time { font-variant-numeric: tabular-nums; }
.rejected-student { color: var(--text); font-weight: 500; }

/* Clickable session rows (closed only). Anchor reset so the row stays
   visually identical to the legacy <div> rows; the cursor + hover lift
   are the only affordance changes. */
.session-row-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.session-row-link:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.attendance-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.attendance-badge.band-good { background: var(--success-light); color: var(--success); }
.attendance-badge.band-warn { background: var(--warning-light); color: var(--warning); }
.attendance-badge.band-low  { background: var(--danger-light);  color: var(--danger); }

/* Student row turns clickable + adds keyboard focus ring */
.student-row-clickable {
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.student-row-clickable:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}
.student-row-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Per-student trend sheet content */
.trend-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.75rem;
}
.trend-pct {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
}
.trend-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.85rem;
}
.trend-strip {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  padding: 0.5rem 0;
}
.trend-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--border);
}
.trend-cell.status-present { background: var(--success); }
.trend-cell.status-absent  { background: var(--danger); }
.trend-cell.status-excused { background: var(--warning); }

.trend-session-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.trend-session {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.trend-session:last-child { border-bottom: none; }
.trend-session-date { font-size: 0.85rem; color: var(--text); }

.section-heading {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.course-hero h3 {
  margin: 0 0 0.25rem;
  color: #fff;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.course-hero-meta {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.course-hero-code {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.course-hero-code-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.7);
}

.course-hero .enrollment-code {
  background: rgba(255, 255, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Stat pills --- */
.stat-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stat-tile {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}

.stat-tile-value {
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.stat-tile-value small {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.75;
  margin-left: 0.05rem;
}

.stat-tile-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
}

/* --- Section headers (sub-page) --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.section-header h2 {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Generic stacked list --- */
.list-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* --- Student row --- */
.student-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

.student-row-main {
  flex: 1;
  min-width: 0;
}

.student-row-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  /* Let long names wrap rather than ellipsis-clip. overflow-wrap: anywhere
     handles strings without spaces (rare for names, common for emails). */
  overflow-wrap: anywhere;
}

.student-row-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  /* "Univ ID . email@auk.edu.kw" - allow wrap so the email stays readable
     instead of getting clipped on narrow viewports. */
  overflow-wrap: anywhere;
  margin-top: 0.1rem;
}

.icon-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.icon-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* --- Session row --- */
.session-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--surface);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.session-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border);
}

.session-status-scheduled::before { background: var(--accent); }
.session-status-active::before    { background: var(--success); }
.session-status-closed::before    { background: var(--text-muted); }
.session-status-cancelled::before { background: var(--danger); }

.date-badge {
  min-width: 48px;
  text-align: center;
  border-right: 1px solid var(--border);
  padding-right: 0.75rem;
}

.date-badge-day {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.date-badge-month {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.session-row-main {
  flex: 1;
  min-width: 0;
}

.session-row-time {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.session-row-status {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.session-status-active .session-row-status    { color: var(--success); }
.session-status-scheduled .session-row-status { color: var(--accent-hover); }
.session-status-cancelled .session-row-status { color: var(--danger); }

.session-row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

/* --- Tabs --- */
.tab-bar {
  display: flex;
  background: var(--surface);
  border-radius: 10px;
  margin: 0.75rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.tab-btn.active .count-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: tabFadeIn 0.2s ease;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Bottom sheet modal --- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 200;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 0.75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 0.9, 0.3, 1);
  z-index: 201;
  max-height: 90vh;
  overflow-y: auto;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 0.75rem;
  cursor: grab;
  touch-action: none;
  /* Larger tap target around the visual indicator */
  padding: 8px 20px;
  background-clip: content-box;
  box-sizing: content-box;
}
.sheet-handle:active { cursor: grabbing; }

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.sheet-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.sheet-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sheet-close:hover {
  background: var(--bg);
  color: var(--text);
}

.sheet-time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sheet-time-row .form-group {
  flex: 1 1 8rem;
  min-width: 0;
}

.sheet-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.sheet-actions .btn {
  flex: 1;
}
