/* ============================================================
   MIND BODY WORKS TELEHEALTH — FOLLOW-UP QUESTIONNAIRE STYLES
   Brand colors per project spec:
   Primary Blue: #003D8F | Navy Accent: #00205B
   Background: #F4F6F9 | Text: #1A1A1A | Border: #C2C9D6
   ============================================================ */

:root {
  --brand-blue: #003D8F;
  --brand-navy: #00205B;
  --bg-light: #F4F6F9;
  --text-dark: #1A1A1A;
  --border-gray: #C2C9D6;
  --white: #FFFFFF;
  --danger: #B3261E;
  --danger-bg: #FDECEA;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.5;
}

/* ---------- HEADER ---------- */
.mbw-header {
  background: var(--brand-blue);
  color: var(--white);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.mbw-header img.logo {
  height: 72px;
  width: 72px;
  border-radius: 50%;
  background: var(--white);
}

.mbw-header h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}

.mbw-header .page-indicator {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.85;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- WIZARD PROGRESS ---------- */
.wizard-progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border-gray);
}

.wizard-progress .step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--border-gray);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

.wizard-progress .step:hover {
  color: var(--brand-blue);
  text-decoration-color: var(--brand-blue);
}

.wizard-progress .step.active { color: var(--brand-blue); font-weight: 600; }
.wizard-progress .step.complete { color: var(--brand-navy); }

.wizard-progress .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-gray);
}

.wizard-progress .step.active .dot,
.wizard-progress .step.complete .dot { background: var(--brand-blue); }

/* ---------- FORM CONTAINER ---------- */
.form-wrap {
  max-width: 900px;
  margin: 24px auto;
  background: var(--white);
  border: 1px solid var(--border-gray);
  border-radius: 6px;
  padding: 28px 32px;
}

.form-step { display: none; }
.form-step.active { display: block; }

fieldset {
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  margin: 0 0 22px 0;
  padding: 16px 18px;
}

legend {
  font-weight: 600;
  color: var(--brand-navy);
  padding: 0 8px;
  font-size: 1rem;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 220px;
}

label { font-size: 0.9rem; font-weight: 500; }

input[type="text"],
input[type="date"],
input[type="email"],
input[type="number"],
textarea,
select {
  padding: 8px 10px;
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}

textarea { min-height: 60px; resize: vertical; }

/* Italicize all "tell us more / please explain" style invitations,
   whether they're placeholder text or static header/label text. */
input::placeholder,
textarea::placeholder {
  font-style: italic;
  color: #8A93A3;
}

.optional-invite {
  font-style: italic;
}

/* ---------- YES/NO + EXPLAIN QUESTIONS ---------- */
.yn-question {
  border-bottom: 1px solid var(--border-gray);
  padding: 12px 0;
}

.yn-question p { margin: 0 0 8px 0; font-weight: 500; }

.yn-options { display: flex; gap: 20px; align-items: center; }
.yn-options label { font-weight: 400; display: flex; align-items: center; gap: 6px; }

.yn-explain {
  margin-top: 8px;
}

.yn-explain textarea {
  width: 100%;
}

.yn-explain textarea.active {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 2px rgba(0, 61, 143, 0.12);
}

/* ---------- BODY SYSTEMS CHECKLIST ---------- */
.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.system-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border-gray);
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--bg-light);
}

.system-item .label-row { display: flex; align-items: center; gap: 10px; }

.system-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
}

.system-label input[type="checkbox"] { width: 20px; height: 20px; }

.system-explain {
  min-height: 44px;
  background: var(--white);
  border: 1px solid var(--border-gray);
}

.system-explain.active {
  border-color: var(--brand-blue);
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(0, 61, 143, 0.12);
}

/* ---------- SCORED QUESTIONNAIRE GRIDS (PHQ-7 / PHQ-9) ---------- */
table.phq-grid {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

table.phq-grid th, table.phq-grid td {
  border: 1px solid var(--border-gray);
  padding: 8px 10px;
  text-align: center;
  font-size: 0.88rem;
}

table.phq-grid th:last-child, table.phq-grid td:last-child {
  text-align: left;
  width: 22%;
}

.phq-comment {
  width: 100%;
  font-size: 0.85rem;
}

table.phq-grid input[type="radio"],
.systems-grid input[type="checkbox"],
.yn-options input[type="radio"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
}

@media (max-width: 700px) {
  table.phq-grid { font-size: 0.78rem; }
  table.phq-grid input[type="radio"] { width: 26px; height: 26px; }
}

table.phq-grid th { background: var(--bg-light); }
table.phq-grid td:first-child, table.phq-grid th:first-child {
  text-align: left;
  width: 40%;
}

/* Visible safety alert, shown by JS when triggered */
.safety-alert {
  display: none;
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: 6px;
  padding: 16px 18px;
  margin-top: 14px;
  color: var(--danger);
}

.safety-alert.show { display: block; }
.safety-alert h3 { margin-top: 0; }
.safety-alert a { color: var(--danger); font-weight: 600; }

/* ---------- BODY MEASURES GRID (measure + client comment, side by side) ---------- */
.measures-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.measure-pair {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 14px;
  border-bottom: 1px dashed var(--border-gray);
  padding-bottom: 10px;
}

.measure-value, .measure-comment {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.measure-comment label { color: #5A6472; font-weight: 400; font-style: italic; }

@media (max-width: 600px) {
  .measure-pair { grid-template-columns: 1fr; }
}

/* ---------- FLOATING BACK-TO-TOP BUTTON ---------- */
.back-to-top-btn {
  position: fixed;
  top: 50%;
  right: 18px;
  transform: translateY(-50%) translateX(12px);
  background: var(--brand-blue);
  color: var(--white);
  border: none;
  border-radius: 24px;
  padding: 12px 14px;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
}

.back-to-top-btn .btn-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-width 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
}

.back-to-top-btn:hover .btn-label {
  max-width: 220px;
  opacity: 1;
  margin-left: 8px;
}

.back-to-top-btn.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}

@media (max-width: 700px) {
  .back-to-top-btn {
    top: auto;
    bottom: 90px;
    right: 14px;
    transform: translateX(12px);
  }
  .back-to-top-btn.show { transform: translateX(0); }
  /* No hover on touch devices -- keep the label visible so it's usable */
  .back-to-top-btn .btn-label {
    max-width: 220px;
    opacity: 1;
    margin-left: 8px;
  }
}

/* ---------- ACTIVITY / DIET RECALL TABLES ---------- */
table.recall-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

table.recall-table th, table.recall-table td {
  border: 1px solid var(--border-gray);
  padding: 5px 6px;
}

table.recall-table th { background: var(--bg-light); }

.diet-totals-row td {
  background: #EAF1F8;
  font-weight: 700;
  text-align: center;
  border-top: 2px solid var(--brand-blue);
}

.recall-columns { display: flex; gap: 20px; }
.recall-columns > div { flex: 1; }

.placeholder-note {
  background: #FFF8E1;
  border: 1px dashed #C9A227;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-top: 10px;
}

/* ---------- NAV BUTTONS ---------- */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
}

button.nav-btn {
  background: var(--brand-blue);
  color: var(--white);
  border: none;
  padding: 10px 22px;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
}

button.nav-btn.secondary {
  background: var(--white);
  color: var(--brand-blue);
  border: 1px solid var(--brand-blue);
}

button.nav-btn:hover { background: var(--brand-navy); }
button.nav-btn.secondary:hover { background: var(--bg-light); }

@media (max-width: 700px) {
  .form-wrap { margin: 0; border-radius: 0; padding: 18px; }
  .recall-columns { flex-direction: column; }
}

.fuq-version-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--border-gray);
  padding: 10px 0 30px;
}


/* ---------- HEADER CLOSE / EXIT BUTTON ---------- */
.mbw-close-btn {
  margin-left: auto;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 50%;
  color: var(--white);
  font-size: 1.15rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.mbw-close-btn:hover,
.mbw-close-btn:focus {
  background: rgba(255,255,255,0.18);
  border-color: var(--white);
}

@media (max-width: 700px) {
  .mbw-close-btn { width: 32px; height: 32px; font-size: 1rem; }
}

/* Password fields on login/register only (.field wrapper).
   Scoped deliberately: index.php uses .form-group and must not be affected. */
.field input[type="password"] {
  padding: 8px 10px;
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

/* index.php intake form layout. These groups had no rule, so labels and
   inputs were rendering inline with browser defaults. */
.form-group {
  display: block;
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 0.9rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}

/* index.php wraps its content in .container, which had no rule.
   Match the .form-wrap card used elsewhere. */
.container {
  max-width: 900px;
  margin: 24px auto;
  background: var(--white);
  border: 1px solid var(--border-gray);
  border-radius: 6px;
  padding: 28px 32px;
}
@media (max-width: 700px) {
  .container { margin: 0; border-radius: 0; padding: 18px; }
}
