/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --white: #ffffff;
  --bg: #f4f6f8;
  --text: #1a2332;
  --text-secondary: #4a5568;
  --border: #d1d9e0;
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-bg: #eaf2f8;
  --success: #1e8449;
  --success-bg: #e8f8f0;
  --warning: #b7950b;
  --warning-bg: #fef9e7;
  --danger: #922b21;
  --danger-bg: #fdedec;
  --info-bg: #ebf5fb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Layout === */
.app-header {
  background: var(--primary);
  color: var(--white);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-lg);
}
.app-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.app-header .subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
  font-weight: 400;
}
.header-badge {
  background: rgba(255,255,255,0.15);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.app-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* === Progress Bar === */
.progress-bar-container {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.progress-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.progress-step {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  position: relative;
  text-align: center;
  flex: 1;
}
.progress-step.active { color: var(--primary); font-weight: 700; }
.progress-step.completed { color: var(--success); }
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* === Cards & Panels === */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--primary);
}
.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.info-box {
  background: var(--info-bg);
  border-left: 4px solid var(--primary-light);
  padding: 0.85rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  line-height: 1.55;
}
.info-box strong { color: var(--primary); }

.warning-box {
  background: var(--warning-bg);
  border-left: 4px solid var(--warning);
  padding: 0.85rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}

/* === Forms === */
label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41,128,185,0.12);
}
textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-group { margin-bottom: 1rem; }

/* === Score Selector (Radio Cards) === */
.score-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.score-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--white);
}
.score-option:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.score-option.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.score-option input[type="radio"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  accent-color: var(--primary);
}
.score-label { font-weight: 700; font-size: 0.92rem; }
.score-desc { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.15rem; line-height: 1.45; }

/* === MMSE Item Rows === */
.mmse-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eef1f5;
  gap: 1rem;
}
.mmse-item:last-child { border-bottom: none; }
.mmse-item-label {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.5;
}
.mmse-item-label .prompt {
  display: block;
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-top: 0.2rem;
}
.mmse-item-score {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.mmse-item-score select {
  width: auto;
  min-width: 60px;
}
.mmse-section-header {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  padding: 0.6rem 0 0.3rem;
  margin-top: 0.5rem;
  border-bottom: 2px solid var(--primary-bg);
}
.mmse-section-points {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* === Photo Upload === */
.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
  margin-bottom: 1rem;
}
.photo-upload-area:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.photo-upload-area.has-image { border-style: solid; border-color: var(--success); background: var(--success-bg); }
.photo-upload-icon { font-size: 2rem; margin-bottom: 0.5rem; display: block; }
.photo-upload-text { font-size: 0.85rem; color: var(--text-secondary); }
.photo-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius);
  margin-top: 0.75rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #27ae60; }

.btn-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #eef1f5;
}

/* === Results === */
.result-score-display {
  text-align: center;
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}
.result-score-display.normal { background: var(--success-bg); border: 2px solid var(--success); }
.result-score-display.mild { background: var(--warning-bg); border: 2px solid var(--warning); }
.result-score-display.moderate { background: #fbeee6; border: 2px solid #e67e22; }
.result-score-display.severe { background: var(--danger-bg); border: 2px solid var(--danger); }

.result-score-number {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.3rem;
}
.result-score-label {
  font-size: 0.9rem;
  font-weight: 600;
}
.result-score-range {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.interpretation-text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 1rem;
}

.clinical-note {
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.clinical-note strong { color: var(--text); }

/* === Disclaimer === */
.disclaimer {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  line-height: 1.55;
  margin-top: 1.5rem;
}
.disclaimer strong { color: var(--warning); }

/* === Section Visibility === */
.screen { display: none; }
.screen.active { display: block; }

/* === Print Styles === */
@media print {
  body { background: white; }
  .app-header { background: var(--primary) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .progress-bar-container, .btn-group, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid var(--border); break-inside: avoid; }
  .result-score-display { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .screen.active { display: block !important; }
}

/* === Responsive === */
@media (max-width: 640px) {
  .app-header { padding: 0.85rem 1rem; }
  .app-container { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .btn-group { flex-direction: column; gap: 0.75rem; }
  .btn-group .btn { width: 100%; justify-content: center; }
}

/* === Verbatim instruction blocks === */
.verbatim {
  background: #f8f5f0;
  border-left: 4px solid #b7950b;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #4a3f2f;
}

/* === Scoring guide toggle === */
.scoring-guide-toggle {
  font-size: 0.82rem;
  color: var(--primary-light);
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: inline-block;
}
.scoring-guide-toggle:hover { text-decoration: underline; }
.scoring-guide-content {
  display: none;
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.82rem;
  line-height: 1.55;
}
.scoring-guide-content.visible { display: block; }

/* Timer */
.timer-display {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  display: inline-block;
  margin-bottom: 1rem;
}

/* Notes textarea in results */
.result-notes {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
}
