/* ============================================================
   css/styles.css — Studio Attendance
   Calm, high-contrast, fast to scan and tap at a busy front desk.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #F5F3EF;
  --surface: #FFFFFF;
  --ink: #1C1B1A;
  --ink-soft: #56524C;
  --ink-faint: #908B83;
  --line: #E4E0D8;
  --accent: #1F6F5C;        /* deep studio green */
  --accent-soft: #E3F0EB;
  --accent-ink: #14503F;
  --present: #1F6F5C;
  --present-soft: #E3F0EB;
  --absent: #C2562F;        /* warm terracotta */
  --absent-soft: #F8E7DE;
  --closed: #908B83;
  --warn: #B8860B;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(28,27,26,0.06), 0 6px 20px rgba(28,27,26,0.05);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

.wrap-wide { max-width: 1080px; }

/* ============================================================
   TOP BAR
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

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

.nav-links { display: flex; gap: 0.4rem; }

.nav-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--surface); color: var(--ink); }
.nav-link.active { background: var(--accent); color: #fff; }

/* ============================================================
   DATE NAVIGATOR (coach view)
   ============================================================ */

.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.date-nav-label {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

.date-nav-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-faint);
  margin-top: 0.1rem;
}

.date-arrow {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 1.1rem;
  color: var(--ink-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.date-arrow:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.today-btn {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  text-decoration: underline;
}

/* ============================================================
   CLASS CARD (coach view)
   ============================================================ */

.class-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.class-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.class-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.class-time {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.class-meta {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.15rem;
}

/* Roster */
.roster { padding: 0.4rem 0.6rem 0.75rem; }

.student-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.55rem;
  border-radius: var(--radius-sm);
}

.student-row + .student-row { border-top: 1px solid var(--line); }

.student-name {
  flex: 1;
  font-size: 0.98rem;
  font-weight: 500;
}

/* Present/Absent toggle */
.toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
}

.toggle button {
  border: none;
  background: none;
  padding: 0.45rem 0.95rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.toggle button.present-on {
  background: var(--present);
  color: #fff;
}

.toggle button.absent-on {
  background: var(--absent);
  color: #fff;
}

/* Class actions */
.class-actions {
  display: flex;
  gap: 0.6rem;
  padding: 0.75rem 1.15rem 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.edited-stamp {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-left: auto;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }

.btn-ghost { background: var(--bg); color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-faint); }

.btn-danger { background: var(--absent-soft); color: var(--absent); border-color: transparent; }
.btn-danger:hover { background: var(--absent); color: #fff; }

.btn-sm { font-size: 0.8rem; padding: 0.45rem 0.8rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   EMPTY / CLOSED STATES
   ============================================================ */

.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ink-faint);
}

.empty-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.empty h3 { font-family: var(--font-display); color: var(--ink-soft); font-weight: 600; margin-bottom: 0.3rem; }
.empty p { font-size: 0.9rem; }

.closed-banner {
  background: repeating-linear-gradient(45deg, #F0EDE7, #F0EDE7 12px, #EAE6DE 12px, #EAE6DE 24px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 1.25rem;
}

.closed-banner strong { font-family: var(--font-display); display: block; font-size: 1.1rem; margin-bottom: 0.2rem; }

.class-card.is-closed { opacity: 0.6; }
.closed-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--closed);
  background: var(--line);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

/* ============================================================
   ADMIN — SECTION HEADERS & FORMS
   ============================================================ */

.section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.section-sub { color: var(--ink-soft); font-size: 0.92rem; margin-bottom: 1.5rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.panel h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="time"],
.field select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--bg);
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.field-row { display: flex; gap: 1rem; }
.field-row .field { flex: 1; }

.help-text { font-size: 0.78rem; color: var(--ink-faint); margin-top: 0.3rem; }

/* Day-of-week picker */
.day-picker { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.day-chip {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.day-chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Student input list */
.student-input-list { display: flex; flex-direction: column; gap: 0.5rem; }

.student-input-row { display: flex; gap: 0.5rem; align-items: center; }
.student-input-row input { flex: 1; }
.student-input-row .remove-x {
  width: 2rem; height: 2rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg);
  color: var(--absent); cursor: pointer; font-size: 1rem; flex-shrink: 0;
}

/* ============================================================
   ADMIN — LISTS & TABLES
   ============================================================ */

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
}

.list-item-main { flex: 1; }
.list-item-title { font-weight: 600; font-size: 0.98rem; }
.list-item-sub { font-size: 0.8rem; color: var(--ink-faint); margin-top: 0.1rem; }

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  margin-right: 0.3rem;
}

/* Data table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--line);
}
.data-table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: none; }

/* Attendance rate bar */
.rate-bar-wrap { display: flex; align-items: center; gap: 0.6rem; }
.rate-bar { flex: 1; height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; min-width: 60px; }
.rate-bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.rate-bar-fill.low { background: var(--absent); }
.rate-bar-fill.mid { background: var(--warn); }
.rate-num { font-weight: 600; font-size: 0.85rem; min-width: 3rem; text-align: right; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.85rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-num { font-family: var(--font-display); font-size: 2rem; font-weight: 600; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--ink-faint); margin-top: 0.3rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Clickable absence count */
.absence-link {
  color: var(--absent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-family: var(--font-body);
}

/* Search box */
.search-box {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--surface);
  margin-bottom: 1rem;
}
.search-box:focus { outline: none; border-color: var(--accent); }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(28,27,26,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 440px; width: 100%;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal h3 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 0.3rem; }
.modal-sub { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 1rem; }
.modal-close { float: right; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--ink-faint); }

.absence-date-item {
  padding: 0.6rem 0.8rem;
  background: var(--absent-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--absent);
}

/* ============================================================
   TOAST
   ============================================================ */

#toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink); color: #fff;
  padding: 0.7rem 1.3rem; border-radius: 999px;
  font-size: 0.88rem; font-weight: 600;
  transition: transform 0.3s; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ============================================================
   UTILITY
   ============================================================ */

.hidden { display: none !important; }
.muted { color: var(--ink-faint); }
.mt { margin-top: 1rem; }
.mt-lg { margin-top: 2rem; }
.center { text-align: center; }
.spinner {
  width: 32px; height: 32px; margin: 3rem auto;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.divider-row { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0; }
.divider-row::before, .divider-row::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.divider-row span { font-size: 0.78rem; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

@media (max-width: 540px) {
  .field-row { flex-direction: column; gap: 0; }
  .class-head { flex-direction: column; gap: 0.3rem; }
  .student-name { font-size: 0.92rem; }
  .toggle button { padding: 0.5rem 0.8rem; }
}
