/* ═══════════════════════════════════════════════════════════════
   Angiogram Study – Styles (complete rewrite)
   ═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #14213d;
  --muted: #5f6b82;
  --primary: #1f6feb;
  --primary-dark: #174ea6;
  --border: #d7dce5;
  --danger: #c02626;
  --success: #1a8c3a;
  --radius: 14px;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* ── Screen infrastructure ─────────────────────────────────── */
.screen {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
}

.hidden { display: none !important; }

/* ── Typography helpers ────────────────────────────────────── */
h1 { font-size: 1.6rem; margin-bottom: 6px; }
h2 { font-size: 1.25rem; margin-bottom: 4px; }
p  { margin-bottom: 10px; line-height: 1.45; }
.muted { color: var(--muted); font-size: 0.92rem; }
.error { color: var(--danger); min-height: 22px; font-size: 0.92rem; }

/* ── Shared components ─────────────────────────────────────── */
.center-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 70dvh;
  gap: 10px;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 4px;
}

input[type="password"],
input[type="number"],
input[type="date"],
.date-input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.05rem;
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  -webkit-appearance: none;
}

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

.btn.primary:active { background: var(--primary-dark); }
.btn.small { min-height: 40px; font-size: 0.9rem; padding: 0 12px; }
.btn.full  { width: 100%; }

.btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Rows ──────────────────────────────────────────────────── */
.row {
  display: flex;
  gap: 10px;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* ── HOME screen ───────────────────────────────────────────── */
.home-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.home-subtitle {
  font-size: 1.05rem;
  color: var(--muted);
}

.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 80px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
}

.action-card:active {
  background: #f0f4ff;
}

.action-card.primary {
  border-color: var(--primary);
  background: #f0f6ff;
}

.action-card.primary:active {
  background: #dce8ff;
}

.action-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.action-text {
  display: flex;
  flex-direction: column;
}

.action-text strong {
  font-size: 1.1rem;
  color: var(--text);
}

.action-text small {
  font-size: 0.88rem;
  color: var(--muted);
}

/* ── Admin ─────────────────────────────────────────────────── */
.admin-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--card);
}

.admin-section summary {
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
}

.admin-inner {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Upload screen ─────────────────────────────────────────── */
.upload-body {
  gap: 14px;
}

.warning {
  background: #fff8e6;
  border: 1px solid #f0d060;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.92rem;
  color: #7a5c00;
  margin-bottom: 10px;
}

input[type="file"] {
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fafbfd;
  font-size: 1rem;
  cursor: pointer;
}

/* ── Review screen ─────────────────────────────────────────── */
.review-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

th {
  background: #f5f7fa;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   SURVEY – Full-screen wizard
   ═══════════════════════════════════════════════════════════════ */

/* When in survey mode, override everything to full-screen */
body.survey-mode {
  overflow: hidden;
}

body.survey-mode #survey-screen {
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
}

/* ── Survey bar ────────────────────────────────────────────── */
.survey-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.progress-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ── Question area ─────────────────────────────────────────── */
.question-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  overflow-y: auto;
}

.q-inner {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.q-label {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

/* ── Choice buttons ────────────────────────────────────────── */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  width: 100%;
  min-height: 60px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.1s;
  -webkit-appearance: none;
}

.choice-btn:active {
  transform: scale(0.97);
}

.choice-btn.selected {
  border-color: var(--primary);
  background: #e8f0ff;
  color: var(--primary-dark);
}

.extracted-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Survey footer ─────────────────────────────────────────── */
.survey-footer {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.survey-footer .btn {
  min-height: 56px;
  font-size: 1.1rem;
}

/* ── Animations ────────────────────────────────────────────── */
.animate-in {
  animation: slideUp 200ms ease-out;
}

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

.shake {
  animation: shake 350ms ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .screen {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .row {
    flex-direction: column;
  }

  .q-label {
    font-size: 1.25rem;
  }
}
