/* ============================================
   Yanne — English Activities
   Design tokens
============================================ */

:root {
  /* Neutrals — warm off-white & stone */
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --surface-3: #efeeec;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #a8a29e;

  /* Accent */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;

  /* Semantic */
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Radii */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================
   Buttons
============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 120ms, border-color 120ms, color 120ms;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost {
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }

/* ============================================
   Inputs
============================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color 120ms;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================================
   Layout
============================================ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 28px; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
  display: block;
}
.brand-mark.lg { width: 42px; height: 42px; border-radius: 11px; }
.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  padding: 8px 14px;
  border-radius: var(--r);
  font-size: 14px;
  color: var(--text-2);
  font-weight: 500;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--surface-2);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

.main {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 28px 80px;
}

/* ============================================
   Cards & sections
============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 0 0 14px;
}

.h1 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.muted { color: var(--text-2); }
.tiny { font-size: 12px; color: var(--text-3); }

/* ============================================
   Badges & pills
============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge.success { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.badge.warning { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }
.badge.dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================
   Track (student levels)
============================================ */
.track {
  position: relative;
  padding: 8px 0;
}
.track-line {
  position: absolute;
  left: 23px;
  top: 36px;
  bottom: 36px;
  width: 2px;
  background: var(--border);
}
.track-line-fill {
  position: absolute;
  left: 23px;
  top: 36px;
  width: 2px;
  background: var(--accent);
  transition: height 400ms ease;
}
.track-node {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
  position: relative;
}
.track-bullet {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  color: var(--text-3);
  flex-shrink: 0;
  z-index: 1;
  font-family: var(--font-mono);
  transition: all 200ms;
}
.track-bullet.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.track-bullet.current {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.track-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  transition: border-color 120ms, transform 120ms;
  text-align: left;
  display: block;
  width: 100%;
}
.track-card.locked {
  background: var(--surface-2);
  border-style: dashed;
  cursor: not-allowed;
  opacity: 0.7;
}
.track-card.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.track-card:not(.locked):hover {
  border-color: var(--border-strong);
}
.track-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.track-card-title {
  font-weight: 600;
  font-size: 15px;
}
.track-card-meta {
  margin-top: 6px;
  display: flex;
  gap: 14px;
  color: var(--text-2);
  font-size: 13px;
}
.activity-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--surface-2);
  display: inline-grid;
  place-items: center;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ============================================
   Stats grid
============================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.stat-value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-trend {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-2);
}

/* ============================================
   Tables
============================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }

.progress {
  position: relative;
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width 400ms ease;
}

/* ============================================
   Login
============================================ */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(ellipse at top, rgba(37,99,235,0.04), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}
.demo-creds {
  margin-top: 22px;
  padding: 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}
.demo-creds code {
  color: var(--text);
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.demo-creds-row { display: flex; justify-content: space-between; padding: 3px 0; }

.error-msg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 13px;
}

/* ============================================
   Misc
============================================ */
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; }

/* ============================================
   List rows (students, activities, questions)
============================================ */
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }

.file-input {
  max-width: 100%;
  padding: 6px 0;
}

/* ============================================
   Tablet
============================================ */
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 28px 20px 70px; }
  .topbar { padding: 12px 20px; }
  .topbar-left { gap: 16px; }
}

/* ============================================
   Phone
============================================ */
@media (max-width: 680px) {
  html, body { font-size: 15px; }

  .topbar {
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .topbar-left { gap: 10px; flex: 1 1 100%; min-width: 0; }
  .topbar-right { flex: 1 1 100%; justify-content: space-between; }
  .brand-name { font-size: 15px; }
  .role-badge { display: none; }
  .user-name { font-size: 13px; }
  .user-chip { padding: 3px 10px 3px 3px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: 8px 12px; white-space: nowrap; }

  .main { padding: 20px 14px 64px; }
  .h1 { font-size: 23px; }
  .h2 { font-size: 17px; }

  .card { padding: 16px; border-radius: var(--r); }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 11px; }

  .list-row { padding: 14px; gap: 10px; }
  .list-row > .row:last-child { width: 100%; justify-content: flex-start; }

  /* Buttons are easier to hit and never overflow */
  .btn { padding: 10px 14px; }
  .btn-sm { padding: 8px 12px; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn { width: 100%; }

  /* Inputs at 16px stop iOS from zooming in on focus */
  .input, input, textarea, select { font-size: 16px; }

  .login-card { padding: 26px 20px; border-radius: 14px; }
  .login-shell { padding: 24px 14px; }

  .activity-row { flex-wrap: wrap; }
  .history-item { grid-template-columns: 28px 1fr; }
  .history-item > :last-child { grid-column: 2; text-align: left !important; }

  /* Legacy tables become stacked rows */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: 12px 14px; }
  .table td { border: 0; padding: 3px 0; }
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

.history-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: 0; }
.history-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
}
.history-icon.success { background: var(--success-soft); color: var(--success); }
.history-icon.accent { background: var(--accent-soft); color: var(--accent); }

.feedback-block {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--r);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
}
.feedback-block .feedback-from {
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 4px;
  font-size: 12px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
}
.empty-state .h2 { color: var(--text); margin-bottom: 6px; }

.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--warning-soft);
  border: 1px solid #fde68a;
  color: var(--warning);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
}

.activity-row {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: 0; }
.activity-row-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding-top: 8px;
}
.bar-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.bar {
  width: 100%;
  background: var(--accent-soft);
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: background 120ms;
}
.bar:hover { background: var(--accent-border); }
.bar-label {
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--font-mono);
}
