/* ============================================================
   MINDLUME PROGRESS NOTE GENERATOR — STYLES
   Brand: Calm, professional, clinician-first
   ============================================================ */

:root {
  --primary:        #2B5EA7;
  --primary-dark:   #1E4480;
  --primary-light:  #EBF2FF;
  --accent:         #6148C8;
  --accent-light:   #F0EBFF;
  --teal:           #2AA89A;
  --teal-light:     #E5F6F4;
  --success:        #276749;
  --success-light:  #E9F5EE;
  --warning:        #B45309;
  --warning-light:  #FEF3C7;
  --danger:         #B91C1C;
  --danger-light:   #FEE2E2;

  --bg:             #F4F7FB;
  --card:           #FFFFFF;
  --text:           #1A1D2E;
  --text-mid:       #4B5568;
  --text-muted:     #8896A7;
  --border:         #E2E8F0;
  --border-focus:   #2B5EA7;

  --shadow-sm:  0 1px 4px rgba(0,0,0,0.07);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.13);

  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 48px;
}

/* ── APP SHELL ──────────────────────────────────────────── */
#app {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  padding: 0 16px;
  flex: 1;
}

/* ── HEADER ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 28px;
}
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
}
.logo-text-wrap { display: flex; flex-direction: column; line-height: 1.1; }
.logo-name { font-size: 18px; font-weight: 700; color: var(--primary); }
.logo-tagline { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: .3px; }

/* ── STEP TRACK ─────────────────────────────────────────── */
.step-track {
  display: flex;
  align-items: center;
  gap: 0;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 0;
}
.step-bubble {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  position: relative;
  z-index: 1;
}
.step-bubble.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 3px var(--primary-light);
}
.step-bubble.done {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}
.step-connector {
  width: 28px;
  height: 2px;
  background: var(--border);
  transition: background .2s;
}
.step-connector.done { background: var(--teal); }

/* ── MAIN CONTENT ───────────────────────────────────────── */
.app-main { flex: 1; padding-bottom: 16px; }

.step-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.step-subheading {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ── CARD ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 16px;
}

/* ── FORM FIELDS ─────────────────────────────────────────── */
.field-group {
  margin-bottom: 20px;
}
.field-group:last-child { margin-bottom: 0; }
.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
  letter-spacing: .2px;
}
.field-group label .req { color: var(--danger); margin-left: 3px; }
.field-group label .opt { color: var(--text-muted); font-weight: 400; font-size: 12px; margin-left: 4px; }

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
}
input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238896A7' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
input.error, select.error, textarea.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-light);
}
.error-msg {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 540px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ── SERVICE TYPE GRID ──────────────────────────────────── */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.service-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  cursor: pointer;
  background: var(--card);
  transition: all .15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
}
.service-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.service-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-md);
}
.service-card .svc-icon { font-size: 24px; }
.service-card .svc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.service-card.selected .svc-name { color: var(--primary-dark); }

/* ── NOTE FORMAT CARDS ──────────────────────────────────── */
.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 600px) { .format-grid { grid-template-columns: 1fr; } }

.format-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  cursor: pointer;
  background: var(--card);
  transition: all .15s;
  user-select: none;
}
.format-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.format-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-md);
}
.format-card .fmt-label {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
}
.format-card .fmt-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.format-card .fmt-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.format-card .fmt-sections {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.fmt-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.format-card:not(.selected) .fmt-badge {
  background: var(--border);
  color: var(--text-muted);
}

/* ── NOTE BUILDER ───────────────────────────────────────── */
.builder-section {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.builder-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.section-letter {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.section-letter.accent  { background: var(--accent); }
.section-letter.teal    { background: var(--teal); }
.section-letter.success { background: var(--success); }

.section-title-wrap { display: flex; flex-direction: column; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); }
.section-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.builder-section-body { padding: 20px; }

/* ── INTERVENTION CHECKBOXES ─────────────────────────────── */
.checkbox-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .12s;
  user-select: none;
}
.checkbox-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.checkbox-item.checked {
  border-color: var(--primary);
  background: var(--primary-light);
}
.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}
.checkbox-item span {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}

/* ── NOTE PREVIEW ───────────────────────────────────────── */
.note-preview {
  background: #FAFBFC;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  font-family: 'Georgia', serif;
  word-wrap: break-word;
}
.note-preview .note-header-block {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 14px;
  margin-bottom: 20px;
}
.note-preview .note-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .5px;
  text-align: center;
  font-family: var(--font);
  margin-bottom: 12px;
}
.note-preview .meta-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 4px;
}
.note-preview .meta-val { font-weight: 600; color: var(--text); }

.note-section-block { margin-bottom: 18px; }
.note-section-label {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
  border-bottom: 1px solid var(--primary-light);
  padding-bottom: 4px;
  margin-bottom: 8px;
}
.note-section-text { font-size: 13.5px; line-height: 1.8; }

.note-sig-block {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 18px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-muted);
}
.sig-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.sig-line-label { font-weight: 600; min-width: 120px; }
.sig-line-blank {
  flex: 1;
  border-bottom: 1px solid var(--text-muted);
  height: 18px;
}

/* ── EXPORT BUTTONS ─────────────────────────────────────── */
.export-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.btn-teal {
  background: var(--teal);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-teal:hover:not(:disabled) {
  background: #228F83;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-accent:hover:not(:disabled) {
  background: #5038B0;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn-outline-danger:hover:not(:disabled) {
  background: var(--danger-light);
}
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }

/* ── FOOTER NAV ─────────────────────────────────────────── */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 28px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  gap: 12px;
}
.footer-left { display: flex; gap: 8px; align-items: center; }
.footer-right { display: flex; gap: 8px; align-items: center; }

/* ── PRIVACY BAR ────────────────────────────────────────── */
.privacy-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1A1D2E;
  color: #C4CFDE;
  font-size: 11.5px;
  text-align: center;
  padding: 7px 16px;
  z-index: 100;
}

/* ── ALERT / INFO BOXES ─────────────────────────────────── */
.info-box {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.info-box.blue {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  color: var(--primary-dark);
}
.info-box.green {
  background: var(--success-light);
  border-left: 3px solid var(--success);
  color: var(--success);
}
.info-box.yellow {
  background: var(--warning-light);
  border-left: 3px solid var(--warning);
  color: var(--warning);
}
.info-box .icon { flex-shrink: 0; font-size: 16px; }

/* ── LOADING ────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── COPY SUCCESS TOAST ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--success);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all .3s;
  z-index: 200;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── MISC UTILITIES ─────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
}

/* ── AI GENERATION ──────────────────────────────────────── */

.btn-ai {
  background: linear-gradient(135deg, var(--accent) 0%, var(--teal) 100%);
  color: #fff;
  border: none;
}
.btn-ai:hover { opacity: 0.9; }
.btn-ai:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-stream-panel {
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
}

.ai-stream-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--accent-light);
  border-bottom: 1px solid #ddd6fe;
  gap: 12px;
}

.ai-stream-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.ai-stream-label.ai-stream-done { color: var(--success); }

.ai-stream-body {
  padding: 20px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  min-height: 120px;
  max-height: 520px;
  overflow-y: auto;
  background: #fff;
}

.ai-cursor {
  display: inline-block;
  color: var(--accent);
  animation: blink 0.9s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.ai-error {
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}
.ai-error code {
  background: #fef2f2;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .app-header { gap: 12px; }
  .step-track { gap: 0; }
  .step-connector { width: 16px; }
  .card { padding: 16px; }
  .note-preview { padding: 18px 14px; }
  .export-row { flex-direction: column; }
  .export-row .btn { width: 100%; justify-content: center; }
}
