@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,700&display=swap");

:root {
  color-scheme: only light;
  --bg: #f5f8fb;
  --bg-accent: #e3edf8;
  --ink: #0f2544;
  --muted: #4b5f7a;
  --accent: #2e6fb9;
  --accent-dark: #1f5590;
  --panel: #ffffff;
  --border: #c7d6e8;
  --shadow: rgba(15, 37, 68, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 20%, #e2edf9 0%, transparent 55%),
    radial-gradient(circle at 80% 10%, #d2e4f7 0%, transparent 50%),
    linear-gradient(150deg, var(--bg) 0%, #eff5fb 55%, #f8fbff 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: rgba(46, 111, 185, 0.12);
  filter: blur(0px);
  z-index: -1;
}

body::before {
  top: -120px;
  left: -120px;
}

body::after {
  bottom: -160px;
  right: -120px;
}

.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  animation: rise 0.8s ease-out;
}

.hero {
  padding: 28px 32px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 20px 40px var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand img {
  height: 54px;
  width: auto;
}

.eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.hero h1 {
  font-family: "Fraunces", serif;
  font-size: clamp(2.1rem, 2.8vw, 3.2rem);
  margin: 0 0 12px;
  line-height: 1.1;
}

.lede {
  margin: 0 0 20px;
  color: var(--muted);
  max-width: 70ch;
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 16px;
}

button {
  font-family: "Space Grotesk", sans-serif;
  border-radius: 999px;
  border: none;
  padding: 12px 24px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(46, 111, 185, 0.28);
}

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
}

.status {
  font-size: 0.95rem;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  padding: 20px 22px;
  box-shadow: 0 12px 24px var(--shadow);
}

.form-section {
  margin-top: 24px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.form-section h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.form h3 {
  margin: 24px 0 12px;
  font-size: 1.1rem;
}

.section-question {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.field-description {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: -4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.medications {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

/* .medication-actions,
.symptom-actions,
.allergy-actions,
.appointment-actions,
.treatment-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 8px;
} */

/* .medication-actions .btn,
.symptom-actions .btn,
.allergy-actions .btn {
  width: auto;
  padding: 6px 16px;
} */

/* .medication-row,
.symptom-row,
.allergy-row {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
} */

.phone-input-group {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.phone-input-group .phone-country-code {
  flex: 0 0 110px;
  min-width: 0;
}

.phone-input-group input {
  flex: 1;
  min-width: 0;
}

label {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
  min-width: 0;
}

input,
select {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: "Space Grotesk", sans-serif;
  background: #fff;
}

input {
  appearance: none;
}

select {
  appearance: auto;
  cursor: pointer;
}

input[readonly] {
  background: var(--bg-accent);
  color: var(--muted);
  cursor: default;
}

.signature-preview {
  margin-top: 12px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font-family: "Brush Script MT", "Segoe Script", "Dancing Script", cursive;
  font-size: 2rem;
  color: var(--ink);
  min-height: 60px;
  line-height: 1.3;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0 16px;
}

.subsection-title {
  font-size: 1.05rem;
  margin: 0 0 8px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.checkbox-label,
label.d-flex:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  cursor: pointer;
  min-height: 44px;
  padding: 4px 0;
}

input[type="checkbox"] {
  appearance: auto;
  border-radius: 3px;
  padding: 0;
  width: 1.1em;
  height: 1.1em;
  cursor: pointer;
}

input:focus,
select:focus {
  outline: 2px solid rgba(232, 107, 58, 0.35);
  border-color: var(--accent);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.badge {
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: #1c1916
}

.transcript {
  min-height: 140px;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
}

.json {
  min-height: 160px;
  background: #1c1916;
  color: #f7e9dc;
  padding: 16px;
  border-radius: 14px;
  overflow-x: auto;
}

/* Declaration Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 37, 68, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}

.modal-dialog {
  pointer-events: auto;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 12px 40px var(--shadow);
  max-width: 680px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.modal-dialog h3 {
  font-family: "Fraunces", serif;
  font-size: 1.3rem;
  margin: 0;
  padding: 24px 28px 0;
  color: var(--ink);
  flex-shrink: 0;
}

.modal-body {
  padding: 20px 28px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink);
}

.modal-body ol {
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 12px;
}

.modal-body ul {
  margin-top: 8px;
  padding-left: 20px;
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

input,
select {
  max-width: 100%;
}

@media (max-width: 720px) {
  .shell {
    padding: 24px 12px 48px;
    gap: 16px;
  }

  .hero {
    padding: 18px 16px;
    border-radius: 16px;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .lede {
    font-size: 0.88rem;
    line-height: 1.5;
    white-space: pre-line;
  }

  .brand img {
    height: 40px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls button {
    width: 100%;
  }

  .panel {
    padding: 14px 14px;
    border-radius: 14px;
  }

  .form.panel {
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
  }

  .form .panel-head {
    padding: 14px 14px 0;
  }

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

  .form-section {
    margin-top: 12px;
    padding: 16px 14px;
    border-radius: 12px;
  }

  .form-section h3 {
    font-size: 1.02rem;
    margin: 0 0 10px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .phone-input-group {
    flex-direction: column;
  }

  .phone-input-group .phone-country-code {
    flex: none;
    width: 100%;
  }

  .signature-preview {
    font-size: 1.5rem;
    padding: 12px 14px;
  }

  .section-question {
    font-size: 0.9rem;
  }

  .field-description {
    font-size: 0.78rem;
  }

  .section-divider {
    margin: 16px 0 12px;
  }

  .subsection-title {
    font-size: 0.98rem;
  }

  /* Dynamic rows: visual separation when stacked */
  .symptom-row,
  .allergy-row,
  .medication-row,
  .pain-area-row,
  .other-condition-row,
  .cancer-history-row,
  .surgical-history-row {
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
  }

  .medications {
    gap: 12px;
  }

  /* Keep add/remove buttons auto-width inside form sections */
  .form-section button {
    width: auto;
  }

  .form-section .btn-sm {
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
  }

  input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .json {
    font-size: 0.8rem;
    padding: 12px;
  }
}