@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Space+Grotesk:wght@500;600&display=swap');

:root {
  /* Neutrals */
  --bg: #F5F4F1;
  --surface: #FFFFFF;
  --border: #DEDCD3;
  --text: #201F2B;
  --text-muted: #625F73;

  /* Brand: indigo/violet (nav, headings, links, secondary buttons) */
  --brand: #534AB7;
  --brand-dark: #3C3489;
  --brand-darker: #26215C;
  --brand-tint: #EEEDFE;
  --brand-tint-border: #AFA9EC;

  /* Accent: coral, reserved for the one primary action per page */
  --accent: #D85A30;
  --accent-dark: #993C1D;
  --accent-tint: #FAECE7;

  --danger: #A32D2D;
  --danger-tint: #FCEBEB;

  /* Status badges */
  --status-open: #0C447C;         --status-open-tint: #E6F1FB;
  --status-assigned: #633806;     --status-assigned-tint: #FAEEDA;
  --status-progress: #3C3489;     --status-progress-tint: #EEEDFE;
  --status-resolved: #173404;     --status-resolved-tint: #EAF3DE;
  --status-closed: #444441;       --status-closed-tint: #F1EFE8;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand-dark); }

h1, h2, .brand, .stat-number {
  font-family: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
}

/* ---------- Top navigation ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.topbar .brand {
  font-weight: 600;
  font-size: 17px;
  color: var(--brand-darker);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-toggle { display: none; }
.nav-toggle-label { display: none; }

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

.topbar nav a, .topbar nav .link-button {
  margin-left: 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.topbar nav a:hover { color: var(--brand-dark); }

.topbar .who {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 18px;
}

.logout-form { display: inline; margin-left: 0; }
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.link-button:hover { color: var(--brand-dark); }

/* ---------- Layout ---------- */

.page {
  max-width: 840px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; color: var(--brand-darker); }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }

.subtitle { color: var(--text-muted); font-size: 14px; margin: 0 0 28px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
}

.center-card { max-width: 380px; margin: 60px auto; }

.login-brand {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field .help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.field input[type="text"], .field input[type="password"], .field input[type="number"],
.field input[type="email"], .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}

.field textarea { min-height: 90px; resize: vertical; }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.pin-input { letter-spacing: 4px; font-size: 18px !important; }

.errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--danger); font-size: 13px; }
.form-error-banner { background: var(--danger-tint); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 18px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover { background: var(--accent-dark); }

.btn-secondary {
  background: transparent;
  color: var(--brand-dark);
  border: 1px solid var(--brand-tint-border);
}
.btn-secondary:hover { background: var(--brand-tint); }

.btn-small { padding: 7px 14px; font-size: 13px; min-height: 36px; }
.full-width { width: 100%; }

/* ---------- Ticket rows & badges ---------- */

.ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover .ticket-title { color: var(--brand-dark); }

.ticket-title { font-weight: 500; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.ticket-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-open { background: var(--status-open-tint); color: var(--status-open); }
.badge-assigned { background: var(--status-assigned-tint); color: var(--status-assigned); }
.badge-in_progress { background: var(--status-progress-tint); color: var(--status-progress); }
.badge-resolved { background: var(--status-resolved-tint); color: var(--status-resolved); }
.badge-closed { background: var(--status-closed-tint); color: var(--status-closed); }

.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { color: var(--brand-tint-border); margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto; }

/* ---------- Multi-student rows ---------- */

.student-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.student-row .field { margin-bottom: 0; }

.remove-student {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  min-height: 44px;
}

/* ---------- Comments ---------- */

.comment { padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

.actions-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.back-link { font-size: 13px; color: var(--text-muted); text-decoration: none; display: inline-block; margin-bottom: 16px; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ---------- Stats & tabs (dashboards) ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--brand-tint); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-card .icon { color: var(--brand); margin-bottom: 6px; }
.stat-number { font-size: 26px; font-weight: 600; color: var(--brand-darker); }
.stat-label { font-size: 12px; color: var(--brand-dark); margin-top: 2px; }

.section-heading-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.section-heading-row.tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.section-heading-row.tabs a { flex-shrink: 0; }

.pill { display: inline-block; font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 20px; background: var(--brand-tint); color: var(--brand-darker); text-transform: capitalize; }
.pill-inactive { background: var(--danger-tint); color: var(--danger); }

.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; min-height: auto; }
.checkbox-field label { margin: 0; }

/* ---------- Data table (desktop) / stacked cards (mobile via media query) ---------- */

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }

/* ---------- Icons ---------- */

.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.icon-brand { color: var(--brand); }

/* =========================================================
   Mobile (<= 640px)
   ========================================================= */
@media (max-width: 640px) {
  .page { padding: 20px 16px 48px; }

  .topbar { padding: 12px 16px; flex-wrap: wrap; }

  .nav-toggle-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    color: var(--brand-dark);
  }

  .topbar nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    order: 3;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }

  .topbar nav a, .topbar nav .who, .topbar nav .logout-form {
    margin-left: 0;
    padding: 10px 4px;
    width: 100%;
  }
  .topbar nav .who { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 14px; }

  .nav-toggle:checked ~ nav { display: flex; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .student-row { grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .remove-student { width: 100%; }

  .ticket-row { flex-wrap: wrap; }

  /* Tables become stacked cards: each row is a card, each cell shows its column label */
  .data-table, .data-table thead, .data-table tbody, .data-table th, .data-table td, .data-table tr { display: block; }
  .data-table thead { display: none; }
  .data-table tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; padding: 4px 12px; }
  .data-table td { border-bottom: none; padding: 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .data-table td:not(:last-child) { border-bottom: 1px solid var(--border); }
  .data-table td::before { content: attr(data-label); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
}
