/* ============================================
   Lifebuoy Pakistan SprintAI_CLT — Survey Flow
   ============================================ */

/* --- Tokens --- */
:root {
  --red:        #E23127;
  --red-dark:   #C4281F;
  --red-light:  #FEF2F2;
  --green:      #0D9F6E;
  --green-dark: #0B8A5E;
  --green-light:#ECFDF5;
  --navy:       #1A2332;
  --slate:      #4B5C6F;
  --muted:      #8896A6;
  --border:     #DDE3EA;
  --surface:    #FFFFFF;
  --bg:         #F0F4F8;
  --amber:      #F59E0B;
  --amber-light:#FFFBEB;
  --radius:     12px;
  --font:       'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--navy);
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 24px 16px 48px;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Header --- */
.header {
  text-align: center;
  padding: 8px 0 0;
}

.brand-bar {
  width: 56px;
  height: 5px;
  background: var(--red);
  border-radius: 3px;
  margin: 0 auto 20px;
}

.study-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--navy);
}

.study-subtitle {
  font-weight: 600;
  color: var(--red);
  font-size: 1.125rem;
}

.study-desc {
  margin-top: 10px;
  font-size: 0.9375rem;
  color: var(--slate);
}

/* --- Return prompt banner --- */
.return-banner {
  background: var(--amber-light);
  border: 1.5px solid var(--amber);
  border-radius: var(--radius);
  padding: 16px 20px;
  animation: bannerSlideIn .3s ease;
}

.return-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 12px;
}

.return-actions {
  display: flex;
  gap: 10px;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
}

/* --- Tracker --- */
.tracker {
  display: flex;
  flex-direction: column;
}

.step {
  display: flex;
  gap: 16px;
}

.step-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 32px;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--muted);
  border: 2px solid var(--border);
  transition: all .3s ease;
}

.step-dot.active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.step-dot.in-progress {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber);
}

.step-dot.done {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.step-line {
  width: 2px;
  flex: 1;
  min-height: 20px;
  background: var(--border);
  border-radius: 1px;
  transition: background .3s ease;
}

.step-line.done {
  background: var(--green);
}

/* --- Step body --- */
.step-body {
  padding-bottom: 28px;
  flex: 1;
  min-width: 0;
}

.step:last-child .step-body {
  padding-bottom: 0;
}

.step-eyebrow {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 2px;
}

.step-title {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.step-text {
  font-size: 0.875rem;
  color: var(--slate);
  margin-bottom: 14px;
}

.step-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--red);
  font-weight: 500;
  line-height: 1.4;
}

.step-note svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 14px 22px;
  cursor: pointer;
  transition: background .2s, opacity .2s, transform .15s;
  width: 100%;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(.97);
}

.btn + .btn {
  margin-top: 10px;
}

.btn-sm {
  width: auto;
  padding: 10px 18px;
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

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

.btn-primary:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-green {
  background: var(--green);
  color: #fff;
}

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

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--slate);
  border: 1.5px solid var(--border);
  font-size: 0.875rem;
  padding: 11px 18px;
}

.btn-ghost:hover {
  background: var(--bg);
  border-color: var(--muted);
}

/* Completed variant */
.btn.completed {
  background: var(--green-light);
  color: var(--green);
  pointer-events: none;
}

/* --- RID badge --- */
.rid-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.rid-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.rid-value {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

/* --- Session counter bar --- */
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.session-counter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--green-light);
  color: var(--green);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0 6px;
}

.session-label {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}

.session-toggle {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.session-toggle:hover {
  background: var(--border);
}

/* --- History panel --- */
.history-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: bannerSlideIn .25s ease;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.history-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--navy);
}

.history-close {
  font-size: 1.25rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

.history-list {
  max-height: 220px;
  overflow-y: auto;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--bg);
}

.history-row:last-child {
  border-bottom: none;
}

.history-rid {
  font-weight: 600;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.history-time {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  margin-left: 12px;
}

@keyframes bannerSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Responsive --- */
@media (max-width: 400px) {
  .card { padding: 22px 16px 16px; }
  .step { gap: 12px; }
  .study-title { font-size: 1.3rem; }
  .btn { font-size: 0.875rem; padding: 13px 16px; }
  .return-banner { padding: 14px 16px; }
  .return-actions { flex-direction: column; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}
