/* ═══════════════════════════════════════════════════════════════════
   DrugOptimal Portal – Styles
   formation.drugoptimal.com
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  --teal:       #06aa9e;
  --teal-dark:  #048f85;
  --teal-deep:  #036e67;
  --teal-light: #e8f8f7;
  --teal-mid:   #b3e8e4;
  --red:        #e53935;
  --gray-50:    #f8fafb;
  --gray-100:   #f1f5f6;
  --gray-200:   #e2e8ea;
  --gray-300:   #cdd5d9;
  --gray-400:   #98a8ae;
  --gray-500:   #6b7c84;
  --gray-600:   #4a5a62;
  --gray-800:   #1e2e34;
  --gray-900:   #0f1e24;
  --radius:     14px;
  --radius-sm:  8px;
  --radius-lg:  20px;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(6,170,158,.08);
  --shadow-lg:  0 4px 8px rgba(0,0,0,.06), 0 12px 40px rgba(6,170,158,.12);
  --font-body:  'Outfit', sans-serif;
  --font-display: 'Lora', serif;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────────────────────────── */
header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  height: 68px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 0 var(--gray-200), 0 2px 8px rgba(0,0,0,.04);
}

.logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-pill {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--teal-dark);
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
  padding: 5px 12px;
  border-radius: 20px;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .83rem;
  font-weight: 500;
  color: var(--gray-500);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.back-btn:hover { color: var(--teal); background: var(--teal-light); }
.back-btn svg { width: 14px; height: 14px; }

/* ── Main Container ────────────────────────────────────────────── */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ── Page Transition ───────────────────────────────────────────── */
.page { animation: fadeUp .35s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero Section ──────────────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 36px; }

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--teal);
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.hero-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-bottom: 12px;
}
.hero h1 em { color: var(--teal); font-style: italic; }

.hero p {
  font-size: .93rem;
  color: var(--gray-500);
  line-height: 1.65;
  max-width: 520px;
  margin: 0 auto;
}

/* ── Option Cards (Home) ───────────────────────────────────────── */
.options-grid { display: flex; flex-direction: column; gap: 14px; }

.option-card {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 22px 24px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  text-align: left;
  width: 100%;
  font-family: var(--font-body);
}
.option-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.option-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--teal-light);
  border: 1.5px solid var(--teal-mid);
  display: flex;
  align-items: center;
  justify-content: center;
}
.option-icon svg { width: 22px; height: 22px; color: var(--teal); }

.option-content { flex: 1; min-width: 0; }

.option-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 5px;
}

.option-desc {
  font-size: .82rem;
  color: var(--gray-500);
  line-height: 1.5;
}

.option-arrow {
  width: 18px;
  height: 18px;
  color: var(--gray-300);
  flex-shrink: 0;
  margin-top: 3px;
  transition: color .15s, transform .15s;
}
.option-card:hover .option-arrow { color: var(--teal); transform: translateX(3px); }

.option-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid var(--teal-mid);
}

/* ── Card Shell ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--teal-light);
  border: 1.5px solid var(--teal-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-header-icon svg { width: 18px; height: 18px; color: var(--teal); }

.card-header-title { font-size: .88rem; font-weight: 600; color: var(--gray-800); }
.card-header-subtitle { font-size: .78rem; color: var(--gray-400); }

.card-body { padding: 24px 28px; }

.card-footer {
  padding: 20px 28px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}

/* ── Section Divider ───────────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 18px;
}

.section-divider-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-divider-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
}

/* ── Branch Selector ───────────────────────────────────────────── */
.branch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0; }

.branch-btn {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
  font-family: var(--font-body);
}
.branch-btn:hover, .branch-btn.active {
  border-color: var(--teal);
  background: var(--teal-light);
}

.branch-btn-title { font-size: .85rem; font-weight: 600; color: var(--gray-800); margin-bottom: 3px; }
.branch-btn-desc { font-size: .76rem; color: var(--gray-500); line-height: 1.4; }

/* ── Info & Warning Boxes ──────────────────────────────────────── */
.info-box {
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .84rem;
  color: var(--gray-600);
  line-height: 1.6;
  margin: 4px 0 16px;
}
.info-box strong { color: var(--gray-800); }

.warning-box {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .84rem;
  color: #5d4037;
  line-height: 1.6;
  margin: 4px 0 16px;
}
.warning-box strong { color: #3e2723; }

/* ── Form Fields ───────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}
label .req { color: var(--teal); margin-left: 2px; }

input[type="text"],
input[type="email"],
textarea,
select {
  width: 100%;
  font-family: var(--font-body);
  font-size: .88rem;
  color: var(--gray-800);
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  outline: none;
  resize: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(6,170,158,.1);
}

input.err, textarea.err { border-color: var(--red); background: #fff5f5; }

.field-err {
  font-size: .76rem;
  color: var(--red);
  margin-top: 5px;
  display: none;
}
.field-err.show { display: block; }

.field-hint {
  font-size: .76rem;
  color: var(--gray-400);
  margin-top: 5px;
  line-height: 1.4;
}

/* ── Email Counter & Tags ──────────────────────────────────────── */
.email-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: .8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  transition: all .2s;
}
.email-counter.empty {
  color: var(--gray-400);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
}
.email-counter.ok {
  color: var(--teal-dark);
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
}
.email-counter.ok::before { content: '\2713'; font-weight: 700; }

.email-counter.warn {
  color: #e65100;
  background: #fff3e0;
  border: 1px solid #ffcc80;
}
.email-counter.warn::before { content: '\26A0'; font-weight: 700; }

.email-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
  max-height: 130px;
  overflow-y: auto;
  padding: 10px;
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
  border-radius: var(--radius-sm);
  display: none;
}
.email-tags.show { display: flex; }

.email-tag {
  font-size: .73rem;
  font-weight: 500;
  color: var(--teal-dark);
  background: #fff;
  border: 1px solid var(--teal-mid);
  padding: 3px 9px;
  border-radius: 20px;
}

/* ── Generated Email Preview ───────────────────────────────────── */
.generated-email {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.generated-email-toolbar {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.generated-email-toolbar span {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-500);
}

.generated-email-body {
  padding: 16px;
  font-size: .83rem;
  color: var(--gray-600);
  line-height: 1.75;
  white-space: pre-wrap;
  font-family: var(--font-body);
}

/* ── Function Chips ────────────────────────────────────────────── */
.func-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.func-chip {
  font-size: .8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-600);
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font-body);
}
.func-chip:hover, .func-chip.active {
  border-color: var(--teal);
  background: var(--teal-light);
  color: var(--teal-dark);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  font-family: var(--font-body);
  font-size: .93rem;
  font-weight: 600;
  color: #fff;
  background: var(--teal);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 12px rgba(6,170,158,.28);
  transition: background .15s, box-shadow .15s, transform .1s;
}
.btn-primary:hover { background: var(--teal-dark); box-shadow: 0 4px 20px rgba(6,170,158,.38); }
.btn-primary:active { transform: scale(.99); }
.btn-primary:disabled { background: var(--gray-300); box-shadow: none; cursor: not-allowed; }
.btn-primary svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-secondary {
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 500;
  color: var(--teal);
  background: var(--teal-light);
  border: 1.5px solid var(--teal-mid);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--teal-mid); }

.btn-copy {
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 500;
  color: var(--teal-dark);
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  transition: background .15s;
}
.btn-copy:hover { background: var(--teal-mid); }

/* ── Success Screen ────────────────────────────────────────────── */
.success-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 28px;
}

.success-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--teal-light);
  border: 2px solid var(--teal-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.success-icon svg { width: 32px; height: 32px; color: var(--teal); }

.success-wrap h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.success-main {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 6px;
}
.success-detail {
  font-size: .88rem;
  color: var(--gray-500);
  line-height: 1.6;
  max-width: 440px;
  margin-bottom: 16px;
}
.success-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .78rem;
  color: var(--gray-400);
  line-height: 1.5;
}

/* Success icon entrance */
@keyframes popIn {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.success-icon {
  animation: popIn .4s ease both;
}

/* ── Spinner ───────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.loading .spinner { display: block; }
.loading .btn-label { display: none; }

/* ── Submit Error Banner ───────────────────────────────────────── */
.submit-error-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff5f5;
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: .84rem;
  font-weight: 500;
  padding: 12px 16px;
  margin-bottom: 12px;
  line-height: 1.5;
  animation: fadeUp .25s ease both;
}
.submit-error-banner span { flex: 1; }
.submit-error-dismiss {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--red);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.submit-error-dismiss:hover { background: rgba(229,57,53,.1); }

/* ── Locked fields during submission ───────────────────────────── */
.field-locked {
  opacity: .55;
  pointer-events: none;
}

/* ── Submit Note ───────────────────────────────────────────────── */
.submit-note {
  font-size: .74rem;
  color: var(--gray-400);
  text-align: center;
  margin-top: 10px;
}
.submit-note strong { color: var(--gray-500); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .branch-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .card-body, .card-footer { padding: 18px 18px; }
  .hero h1 { font-size: 1.65rem; }
  main { padding: 28px 14px 60px; }
  header { padding: 0 16px; }
}
