/*
 * styles.css — all presentation for the frailty app.
 * Extracted from index.html so the page can run under a strict CSP
 * (no inline <style>, no style="" attributes, no inline scripts).
 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  /* NOTE: no overflow:hidden here — it would break position:sticky on the banner. */
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- header ---------- */

.header {
  background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
  color: white;
  padding: 30px;
  text-align: center;
  border-radius: 12px 12px 0 0;
}

.header h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}

.header p {
  font-size: 14px;
  opacity: 0.9;
}

/* ---------- sticky patient banner ---------- */

.patient-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 30px;
  background: #f4f7fb;
  border-bottom: 1px solid #dbe3ee;
  border-left: 4px solid #3498db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pb-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 20px;
  min-width: 0;
}

.pb-name {
  font-size: 19px;
  font-weight: 700;
  color: #1b2a3a;
}

.pb-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.pb-field {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.pb-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #6b7c8f;
}

.pb-value {
  font-size: 14px;
  font-weight: 600;
  color: #2c3e50;
}

.pb-session {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#session-countdown {
  font-variant-numeric: tabular-nums;
}

#session-countdown.warning {
  color: #a02b2b;
}

.pb-logout {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #34495e;
  background: #fff;
  border: 1px solid #c6d2e0;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}

.pb-logout:hover {
  background: #eef3f9;
}

.pb-logout:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- content ---------- */

.content {
  padding: 30px;
}

/* ---------- branded loader ---------- */

.loading {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.brand-mark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #3498db;
}

.loading-text {
  font-size: 16px;
  margin-top: 6px;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 18px auto;
  border: 3px solid #e3eaf3;
  border-top-color: #3498db;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner-sm {
  width: 18px;
  height: 18px;
  margin: 0;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

.scores-pending {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  color: #5a6b7c;
  font-size: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 24px;
}

/* ---------- disclaimer ---------- */

.disclaimer {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 13px;
  color: #856404;
}

.disclaimer strong {
  display: block;
  margin-bottom: 5px;
}

/* ---------- degraded-data notices ---------- */

.notices {
  background: #fdf3e7;
  border-left: 4px solid #e8933a;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
  color: #7a4d17;
  font-size: 13px;
}

.notices h3 {
  font-size: 15px;
  margin-bottom: 6px;
}

.notices ul {
  margin: 8px 0 0 20px;
  line-height: 1.6;
}

.notice-quote {
  font-style: italic;
}

/* ---------- score cards ---------- */

.scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  margin-bottom: 30px;
}

.score-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 25px;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.score-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}

.score-title {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
}

.score-subtitle {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}

.score-value {
  font-size: 36px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  min-width: 70px;
  text-align: center;
}

.score-low {
  background: #d4edda;
  color: #155724;
}

.score-medium {
  background: #fff3cd;
  color: #856404;
}

.score-high {
  background: #f8d7da;
  color: #721c24;
}

.score-items {
  display: grid;
  gap: 10px;
}

.score-item {
  display: flex;
  align-items: center;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 14px;
}

.score-item.present {
  background: #e3f2fd;
  border-left: 3px solid #2196F3;
}

.score-item.absent {
  opacity: 0.5;
}

.score-item::before {
  margin-right: 10px;
  font-weight: 700;
  font-size: 16px;
}

.score-item.present::before {
  content: "✓";
  color: #2196F3;
}

.score-item.absent::before {
  content: "○";
  color: #999;
}

/* ---------- clinician override ---------- */

.override-panel {
  margin-top: 30px;
  padding: 20px 25px;
  background: #fffaf0;
  border-left: 4px solid #f0ad4e;
  border-radius: 8px;
}

.override-panel h3 {
  color: #8a6d3b;
  font-size: 16px;
  margin-bottom: 8px;
  font-weight: 600;
}

.override-note {
  font-size: 13px;
  color: #8a6d3b;
  margin-bottom: 15px;
  line-height: 1.5;
}

.override-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 15px;
  background: #fff;
  border: 1px solid #f0e0c0;
  border-radius: 6px;
  margin-bottom: 10px;
  cursor: pointer;
}

.override-item:last-child {
  margin-bottom: 0;
}

.override-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
}

.override-text {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: #2c3e50;
}

.override-help {
  font-size: 12px;
  color: #888;
  margin-top: 3px;
}

.override-evidence {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  border-radius: 4px;
  padding: 6px 10px;
}

.override-evidence.override-dep {
  color: #8a3b3b;
  background: #fdecec;
}

.override-evidence.override-indep {
  color: #5a7d2a;
  background: #f4f9ec;
}

.override-evidence.override-unknown {
  color: #7a6a4a;
  background: #faf6ed;
}

.override-evidence ul {
  margin: 4px 0 0 18px;
}

.override-evidence li {
  margin-bottom: 2px;
}

/* ---------- interpretation ---------- */

.interpretation {
  margin-top: 30px;
  padding: 20px;
  background: #e8f4f8;
  border-left: 4px solid #2196F3;
  border-radius: 8px;
}

.interpretation h3 {
  color: #1976D2;
  font-size: 16px;
  margin-bottom: 12px;
  font-weight: 600;
}

.interpretation p {
  color: #555;
  line-height: 1.6;
  font-size: 14px;
  margin-bottom: 10px;
}

.interpretation p.spaced {
  margin-top: 15px;
}

.interpretation p.footnote {
  margin-top: 15px;
  font-size: 12px;
  color: #666;
}

/* ---------- conditions ---------- */

.conditions-section {
  margin-top: 30px;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 25px;
}

.conditions-section h3 {
  color: #2c3e50;
  font-size: 18px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
}

.conditions-section h3::before {
  content: "📋";
  margin-right: 8px;
  font-size: 20px;
}

.conditions-list {
  display: grid;
  gap: 8px;
}

.condition-item {
  background: white;
  padding: 12px 15px;
  border-radius: 6px;
  border-left: 3px solid #3498db;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.condition-item::before {
  content: "•";
  color: #3498db;
  font-weight: 700;
  margin-right: 10px;
  font-size: 18px;
}

.empty-note {
  color: #666;
  font-style: italic;
}

/* ---------- terminal views ---------- */

.error {
  background: #f8d7da;
  color: #721c24;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #dc3545;
  margin: 20px 0;
}

.error h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.error p {
  line-height: 1.6;
  font-size: 14px;
}

.error pre {
  background: #fff;
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  margin-top: 10px;
}

.session-expired {
  background: #eef2f7;
  border-left: 4px solid #6b7c8f;
  border-radius: 8px;
  padding: 28px 24px;
  margin: 20px 0;
  color: #2c3e50;
}

.session-expired h3 {
  font-size: 20px;
  margin-bottom: 10px;
}

.session-expired p {
  font-size: 15px;
  line-height: 1.6;
}

.session-expired-note {
  margin-top: 10px;
  font-size: 13px;
  color: #5a6b7c;
}

/* ---------- debug ---------- */

.debug-section {
  margin-top: 30px;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
}

.debug-section h3 {
  color: #2c3e50;
  font-size: 16px;
  margin-bottom: 15px;
  cursor: pointer;
  user-select: none;
}

.debug-section h3::before {
  content: "▶ ";
  display: inline-block;
  transition: transform 0.2s;
}

.debug-section h3.expanded::before {
  transform: rotate(90deg);
}

.debug-content {
  display: none;
  background: #2c3e50;
  color: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.debug-content.visible {
  display: block;
}

/* ---------- footer ---------- */

.footer {
  background: #f8f9fa;
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: #666;
  border-top: 1px solid #e0e0e0;
  border-radius: 0 0 12px 12px;
}

.footer-fine {
  margin-top: 8px;
  font-size: 11px;
}

/* ---------- responsive ---------- */

@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .container {
    border-radius: 0;
  }

  .header,
  .footer {
    border-radius: 0;
  }

  .scores-grid {
    grid-template-columns: 1fr;
  }

  .patient-banner {
    padding: 12px 20px;
  }

  .content {
    padding: 20px;
  }

  .header h1 {
    font-size: 24px;
  }
}
