/* TheraMap Clinical Styles - Professional Medical Aesthetic */
:root {
  --primary: #0f766e; /* teal-700 */
  --primary-dark: #134e4a;
  --primary-light: #14b8a6;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-600: #475569;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --red-600: #dc2626;
  --amber-500: #f59e0b;
  --white: #ffffff;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--slate-50);
  color: var(--slate-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo span {
  color: var(--slate-800);
}

.nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav a {
  color: var(--slate-600);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.nav a:hover, .nav a.active {
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--slate-200);
  color: var(--slate-800);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--red-600);
  color: white;
}

/* Main layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--slate-200);
}

/* Auth forms */
.auth-container {
  max-width: 420px;
  margin: 3rem auto;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--slate-800);
  font-size: 0.875rem;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.error-msg {
  color: var(--red-600);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.success-msg {
  color: var(--primary);
  font-size: 0.875rem;
}

/* Disclaimer */
.disclaimer {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-left: 4px solid var(--amber-500);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: #92400e;
  margin-bottom: 1.5rem;
}

.disclaimer strong {
  display: block;
  margin-bottom: 0.25rem;
}

/* Body Map */
.body-map-container {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .body-map-container {
    grid-template-columns: 1fr;
  }
}

.map-wrapper {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  padding: 1rem;
  text-align: center;
}

.map-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.view-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--slate-200);
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
}

.view-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.svg-container {
  max-width: 400px;
  margin: 0 auto;
  overflow: visible;
}

.svg-container svg {
  width: 100%;
  height: auto;
}

.body-region {
  fill: #cbd5e1;
  stroke: #64748b;
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 0.2s, stroke 0.2s;
}

.body-region:hover {
  fill: #99f6e4;
  stroke: var(--primary);
}

.body-region.selected {
  fill: #0d9488;
  stroke: #134e4a;
  stroke-width: 2.5;
}

.region-label {
  font-size: 10px;
  fill: #334155;
  pointer-events: none;
  font-weight: 500;
}

.selected-panel {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  padding: 1.25rem;
  position: sticky;
  top: 80px;
}

.selected-panel h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--slate-800);
}

.selected-list {
  list-style: none;
  margin-bottom: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.selected-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--slate-100);
  font-size: 0.875rem;
}

.selected-list li button {
  background: none;
  border: none;
  color: var(--red-600);
  cursor: pointer;
  font-size: 0.75rem;
}

.empty-selected {
  color: var(--slate-600);
  font-size: 0.875rem;
  font-style: italic;
}

/* Results */
.results-section {
  display: none;
}

.results-section.visible {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--slate-800);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

.item-card {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.item-card h4 {
  color: var(--primary-dark);
  margin-bottom: 0.5rem;
}

.item-card .meta {
  font-size: 0.8125rem;
  color: var(--slate-600);
  margin-bottom: 0.5rem;
}

.red-flag {
  background: #fef2f2;
  border-color: #fecaca;
  border-left: 4px solid var(--red-600);
}

.red-flag h4 {
  color: var(--red-600);
}

details.item-card {
  cursor: pointer;
}

details.item-card summary {
  list-style: none;
  font-weight: 600;
  color: var(--primary-dark);
}

details.item-card summary::-webkit-details-marker {
  display: none;
}

details.item-card[open] summary {
  margin-bottom: 0.75rem;
}

.steps {
  white-space: pre-wrap;
  font-size: 0.875rem;
  background: white;
  padding: 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid var(--slate-200);
  margin-top: 0.5rem;
}

/* Footer */
.footer {
  background: var(--slate-800);
  color: #94a3b8;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  margin-top: 3rem;
}

.footer a {
  color: #cbd5e1;
}

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--slate-600);
}

.spinner {
  border: 3px solid var(--slate-200);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* ===== Print / PDF styles ===== */
@media print {
  .header, .footer, .map-controls, .selected-panel, #generateBtn, #darkModeBtn, #saveSessionBtn, #newAssessmentBtn, .view-btn, button, .disclaimer {
    display: none !important;
  }
  .body-map-container {
    grid-template-columns: 1fr;
  }
  .map-wrapper, .svg-container {
    display: none !important;
  }
  .results-section {
    display: block !important;
  }
  .item-card, details.item-card {
    break-inside: avoid;
    border: 1px solid #ccc;
    margin-bottom: 0.5rem;
  }
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
  }
  .section-header {
    border-bottom: 2px solid #333;
    color: #000;
  }
}

/* Dark mode helper classes */
.dark-mode {
  --slate-50: #0f172a;
  --white: #1e293b;
}

/* ===== Mobile / Tablet improvements ===== */
@media (max-width: 768px) {
  .body-map-container {
    grid-template-columns: 1fr;
  }
  .selected-panel {
    order: -1;
  }
  .svg-container svg {
    max-height: 55vh;
  }
  .item-card details summary {
    padding: 0.75rem;
    font-size: 1rem;
  }
  .btn {
    min-height: 44px; /* better touch targets */
    padding: 0.65rem 1rem;
  }
  input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
  }
  .header .nav a {
    font-size: 0.8125rem;
    padding: 0.35rem 0.5rem;
  }
  #resultsContent {
    font-size: 0.9375rem;
  }
}
