/* TriageRAG human-evaluation stylesheet — designed for senior physicians.
   Optimized for: large fonts, high contrast, big tap targets, low cognitive load.
*/

* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #f4f6f5;
  color: #111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "Noto Sans", "Liberation Sans", Arial, sans-serif;
  font-size: 1.1rem;
  line-height: 1.65;
}

/* Layout ------------------------------------------------------------- */
.topbar {
  background: #0e7c66;
  color: white;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { color: white; font-weight: 700; text-decoration: none; font-size: 1.2rem; }
.logout-btn {
  color: white;
  background: rgba(255,255,255,0.2);
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.95rem;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.logout-btn:hover { background: rgba(255,255,255,0.3); }

.page {
  max-width: 920px;
  margin: 28px auto 80px;
  padding: 0 22px;
}
.footer {
  text-align: center;
  color: #777;
  padding: 30px 20px 60px;
}

/* Typography --------------------------------------------------------- */
h1 { font-size: 1.9rem; margin: 0 0 16px; color: #0e3a32; }
h2 { font-size: 1.35rem; margin: 24px 0 12px; color: #0e3a32; }
h3 { font-size: 1.15rem; margin: 0; color: #0e3a32; }
.lead { font-size: 1.2rem; }
.muted { color: #666; }

/* Cards -------------------------------------------------------------- */
.login-card, .welcome-card, .done-card, .register-card {
  background: white;
  border-radius: 14px;
  padding: 32px 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  max-width: 720px;
  margin: 0 auto;
}

/* Registration form ------------------------------------------------- */
.register-card form { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label {
  font-weight: 600;
  font-size: 1.05rem;
  color: #0e3a32;
}
.field-group input[type="text"],
.field-group input[type="number"],
.field-group input[type="email"],
.field-group select {
  font-size: 1.1rem;
  padding: 12px 14px;
  border: 2px solid #cfd8d4;
  border-radius: 10px;
  background: white;
  color: #111;
}
.field-group input:focus,
.field-group select:focus {
  outline: none;
  border-color: #0e7c66;
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.15);
}
.field-group small.muted {
  color: #777;
  font-size: 0.92rem;
}
.req { color: #b00020; font-weight: 700; }
.optional { color: #888; font-weight: 400; font-size: 0.9rem; }

.radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid #cfd8d4;
  border-radius: 10px;
  cursor: pointer;
  background: #fdfdfc;
  transition: all 0.15s;
  min-height: 56px;
}
.radio-card input[type="radio"] {
  width: 22px; height: 22px;
  accent-color: #0e7c66;
}
.radio-card:hover { border-color: #0e7c66; }
.radio-card:has(input:checked) {
  background: #e8f3f0;
  border-color: #0e7c66;
}

/* Profile summary on welcome page */
.profile-summary {
  background: #f8faf9;
  border-left: 4px solid #0e7c66;
  padding: 14px 18px;
  border-radius: 8px;
  margin: 16px 0 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 18px;
  font-size: 0.98rem;
}
.login-card form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card label { font-weight: 600; font-size: 1.05rem; }
.login-card input[type="text"] {
  font-size: 1.4rem;
  padding: 14px 16px;
  border: 2px solid #cfd8d4;
  border-radius: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.login-card input[type="text"]:focus {
  outline: none;
  border-color: #0e7c66;
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.15);
}
.error {
  color: #b00020;
  background: #fde7e9;
  padding: 12px 14px;
  border-radius: 8px;
  margin: 0;
}

/* Buttons ------------------------------------------------------------ */
.primary, .secondary {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  border-radius: 12px;
  padding: 14px 22px;
  border: 0;
  cursor: pointer;
  min-height: 56px;
  font-size: 1.1rem;
}
.primary {
  background: #0e7c66;
  color: white;
}
.primary:hover { background: #0a5e4d; }
.secondary {
  background: white;
  color: #0e7c66;
  border: 2px solid #0e7c66;
}
.secondary:hover { background: #e8f3f0; }
.big { font-size: 1.25rem; padding: 16px 28px; }

/* Welcome ------------------------------------------------------------ */
.dim-list, .tip-list {
  padding-left: 1.4em;
  margin: 0 0 14px;
}
.dim-list li, .tip-list li { margin-bottom: 8px; }

/* Question page ------------------------------------------------------ */
.progress-row {
  margin-bottom: 18px;
}
.progress-text {
  margin-bottom: 6px;
  font-size: 1.05rem;
  color: #0e3a32;
}
.progress-bar {
  background: #e2e8e6;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.progress-fill {
  background: #0e7c66;
  height: 100%;
  transition: width 0.4s ease;
}

.break-banner {
  background: #fff5cc;
  border: 1px solid #f0c040;
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.warn-banner {
  background: #fff0e6;
  border-left: 6px solid #d97757;
  padding: 16px 18px;
  border-radius: 10px;
  margin-top: 22px;
  line-height: 1.65;
  color: #5a2c10;
}
.warn-banner strong { color: #5a2c10; }

/* Calm blue informational banner — used for the welcome page's recovery-ID
   notice ("Mã định danh của bạn: D7"). Tone is "remember this", not "warning". */
.info-banner {
  background: #e8f1fb;
  border-left: 6px solid #2c6dc7;
  padding: 14px 18px;
  border-radius: 10px;
  margin: 18px 0 22px;
  line-height: 1.6;
  color: #143a6b;
}
.info-banner strong { color: #143a6b; }
.info-banner code {
  background: #d6e4f5;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Green payment banner — calmer hue than the orange warn-banner so the
   student understands the message is informational, not a warning. */
.payment-banner {
  background: #e8f6ee;
  border-left: 6px solid #2f9d59;
  padding: 14px 18px;
  border-radius: 10px;
  margin: 18px 0 22px;
  line-height: 1.6;
  color: #1d4d2e;
}
.payment-banner strong { color: #1d4d2e; }

/* Inline notice inside the registration form's payment section. Lighter
   than .payment-banner because it lives among other form fields. */
.payment-notice {
  background: #f1faf4;
  border: 1px solid #b6dfc1;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  line-height: 1.55;
  font-size: 0.95em;
  color: #1d4d2e;
}

/* Pill shown next to fully-completed students in the admin doctors table. */
.eligible-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78em;
  background: #2f9d59;
  color: #fff;
  font-weight: 600;
}

.zh-banner {
  background: #fff0e6;
  border-left: 6px solid #d97757;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 1rem;
  color: #5a2c10;
  line-height: 1.55;
}

.zh-tag {
  display: inline-flex;
  align-items: center;
  background: #fde7e0;
  color: #b04400;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 8px;
  border: 1px solid #f0a880;
}

.question-card {
  background: white;
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  border-left: 6px solid #0e7c66;
}
.qlabel {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0e7c66;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.qtext {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
  color: #102a25;
}

.instruction {
  margin: 4px 0 14px;
  color: #555;
}

.answer-block {
  background: white;
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.ans-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.slot-badge {
  display: inline-block;
  background: #0e7c66;
  color: white;
  font-weight: 800;
  width: 36px;
  height: 36px;
  line-height: 36px;
  text-align: center;
  border-radius: 50%;
  font-size: 1.1rem;
}
.ans-text {
  background: #f8faf9;
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 1.08rem;
  line-height: 1.7;
}

/* Rating table ------------------------------------------------------- */
.rating-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.rating-table th, .rating-table td {
  padding: 10px 6px;
  text-align: center;
  border-bottom: 1px solid #eee;
}
.rating-table th {
  font-weight: 600;
  color: #0e3a32;
  font-size: 0.95rem;
}
.rating-table th small { color: #666; font-weight: normal; font-size: 0.8rem; }
.dim-col {
  text-align: left;
  width: 28%;
  position: relative;
}
.dim-help {
  display: inline-block;
  background: #cfd8d4;
  color: #0e3a32;
  width: 22px; height: 22px;
  text-align: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: help;
  margin-left: 4px;
  line-height: 22px;
}
.dim-tip {
  display: none;
  position: absolute;
  background: #102a25;
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  z-index: 10;
  width: 240px;
  top: 100%;
  left: 0;
  font-weight: normal;
  line-height: 1.4;
}
.dim-col:hover .dim-tip,
.dim-help:hover + .dim-tip { display: block; }

/* Custom big radio buttons ------------------------------------------ */
.radio-cell {
  display: inline-block;
  cursor: pointer;
  user-select: none;
}
.radio-cell input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.radio-visual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: white;
  border: 2px solid #cfd8d4;
  font-weight: 700;
  font-size: 1.15rem;
  color: #102a25;
  transition: all 0.15s ease;
}
.radio-cell:hover .radio-visual { border-color: #0e7c66; }
.radio-cell input[type="radio"]:checked + .radio-visual {
  background: #0e7c66;
  border-color: #0e7c66;
  color: white;
}
.radio-cell input[type="radio"]:focus-visible + .radio-visual {
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.3);
}

/* Note input --------------------------------------------------------- */
.note-details {
  margin-top: 14px;
}
.note-details summary {
  cursor: pointer;
  font-size: 0.95rem;
  color: #555;
  padding: 8px 0;
}
.note-details summary:hover { color: #0e7c66; }
.note-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cfd8d4;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  margin-top: 8px;
}
.note-input:focus { outline: none; border-color: #0e7c66; box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.15); }

/* Navigation row ----------------------------------------------------- */
.navrow {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
  flex-wrap: wrap;
}
.navrow > * { flex: 1 1 200px; }

.autosave-note {
  text-align: center;
  color: #666;
  margin-top: 16px;
  font-size: 0.95rem;
}
.autosave-note.saving { color: #0e7c66; }
.autosave-note.saved::before { content: "✓ "; color: #0e7c66; font-weight: 700; }
.autosave-note.error { color: #b00020; }

/* ============================================================
   Mobile (<= 640px) — optimized for senior physicians on phones
   ============================================================ */
@media (max-width: 640px) {
  html { font-size: 17px; }
  .page { padding: 0 14px; margin-top: 16px 0 60px; }

  /* Slimmer top bar (mobile real estate is precious). */
  .topbar { padding: 10px 14px; }
  .brand { font-size: 1rem; }
  .logout-btn { padding: 6px 10px; font-size: 0.9rem; min-height: 36px; }

  /* Cards tighter on phones. */
  .login-card, .welcome-card, .done-card, .register-card,
  .question-card, .answer-block { padding: 18px 14px; }
  .question-card { border-left-width: 4px; }
  .qtext { font-size: 1.18rem; line-height: 1.55; }
  .ans-text {
    padding: 14px 14px;
    font-size: 1rem;
    line-height: 1.7;
  }

  /* Convert the rating <table> into stacked dimension cards.
     Each dimension shows: label (with help text inline) on its own row,
     then 5 big radio buttons below, fitting in any phone width. */
  .rating-table { border: none; }
  .rating-table thead { display: none; }
  .rating-table tbody, .rating-table tr { display: block; }
  .rating-table tr {
    display: block;
    background: #f7faf9;
    border: 1px solid #e2e8e6;
    border-radius: 12px;
    padding: 12px 12px 8px;
    margin-bottom: 12px;
  }
  .rating-table td {
    display: inline-block;
    border: none;
    padding: 0;
  }
  .rating-table td.dim-col {
    display: block;
    width: 100%;
    text-align: left;
    font-size: 1.05rem;
    margin-bottom: 10px;
    position: static;
  }
  .rating-table td.dim-col strong {
    display: inline-block;
    color: #0e3a32;
    margin-right: 4px;
    font-size: 1.08rem;
  }
  /* Drop the "?" icon and show help text inline on mobile (no hover). */
  .dim-help { display: none; }
  .dim-tip {
    display: block;
    position: static;
    background: transparent;
    color: #555;
    padding: 0;
    width: auto;
    font-size: 0.95rem;
    font-weight: normal;
    line-height: 1.5;
    margin-top: 2px;
  }

  /* Big finger-friendly radios — 50px is just over Apple HIG (44px). */
  .rating-table td:not(.dim-col) {
    margin-right: 4px;
    margin-bottom: 4px;
  }
  .rating-table td:not(.dim-col):last-child { margin-right: 0; }
  .radio-visual { width: 52px; height: 52px; font-size: 1.15rem; }
  .radio-cell { display: inline-block; }

  /* Slot badge slightly smaller, header allows wrapping for the zh-tag. */
  .ans-header { flex-wrap: wrap; gap: 8px; }
  .slot-badge { width: 32px; height: 32px; line-height: 32px; }
  .ans-header h3 { font-size: 1.05rem; }
  .zh-tag { font-size: 0.78rem; padding: 3px 8px; margin-left: 0; }

  /* Full-width nav buttons; primary first so it's reachable by thumb. */
  .navrow {
    flex-direction: column-reverse;
    gap: 10px;
    margin-top: 24px;
  }
  .navrow > * {
    flex: 1 1 auto;
    width: 100%;
    min-height: 60px;
  }

  /* Notes textarea easier to tap into. */
  .note-details summary { padding: 12px 0; }
  .note-input { font-size: 1.02rem; padding: 12px; }

  /* Registration form: tighter on phone. */
  .register-card form { gap: 14px; }
  .field-group label { font-size: 1.02rem; }
  .field-group input, .field-group select {
    font-size: 1.05rem;
    padding: 12px 12px;
  }
  .radio-group { grid-template-columns: 1fr; gap: 8px; }
  .radio-card { padding: 12px; min-height: 60px; }

  /* Profile summary stacks vertically. */
  .profile-summary { grid-template-columns: 1fr; gap: 6px; padding: 12px 14px; }

  /* Banners more compact. */
  .warn-banner, .zh-banner, .break-banner {
    padding: 12px 14px;
    font-size: 0.97rem;
    line-height: 1.55;
  }
}

/* Very narrow phones (older Androids / iPhone SE 1st gen, <= 360px). */
@media (max-width: 360px) {
  .radio-visual { width: 46px; height: 46px; font-size: 1.05rem; }
  .rating-table tr { padding: 10px 8px 6px; }
  .rating-table td:not(.dim-col) { margin-right: 2px; }
}
