/* ============================================================
   Wicanja Health — Global Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500&family=DM+Serif+Display&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'DM Sans', sans-serif;
}

:root {
  /* Brand colours — change these to restyle the entire app */
  --color-bg:            #000000;
  --color-surface:       rgba(255,255,255,0.05);
  --color-surface-hover: rgba(255,255,255,0.08);
  --color-border:        rgba(255,255,255,0.10);
  --color-border-focus:  rgba(45,212,191,0.80);

  --color-text:          #ffffff;
  --color-text-muted:    rgba(255,255,255,0.40);
  --color-text-faint:    rgba(255,255,255,0.20);

  --color-accent:        #2dd4bf;               /* teal-400  */
  --color-accent-dim:    rgba(45,212,191,0.15);
  --color-accent-label:  rgba(45,212,191,0.80);

  --color-indigo-dim:    rgba(99,102,241,0.15);
  --color-indigo-border: rgba(99,102,241,0.20);
  --color-indigo-text:   #a5b4fc;

  --color-danger:        #f87171;
  --color-danger-bg:     rgba(239,68,68,0.10);
  --color-danger-border: rgba(239,68,68,0.30);

  --color-success:       #4ade80;

  /* Ambient blob colours */
  --blob-1:  rgba(19,78,74,0.25);    /* teal-900  */
  --blob-2:  rgba(49,46,129,0.25);   /* indigo-900 */

  /* Typography */
  --font-sans:  'DM Sans', sans-serif;
  --font-serif: 'DM Serif Display', serif;

  /* Shape */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-full: 9999px;
}

html, body {
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: var(--font-serif); }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes blob {
  0%   { transform: translate(0,0) scale(1);     }
  33%  { transform: translate(30px,-50px) scale(1.1); }
  66%  { transform: translate(-20px,20px) scale(0.9); }
  100% { transform: translate(0,0) scale(1);     }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50%     { opacity: .4; }
}
@keyframes blink {
  0%,80%,100% { opacity: .2; transform: scale(1);   }
  40%         { opacity: 1;  transform: scale(1.35); }
}
@keyframes float {
  0%,100% { transform: translateY(0);     }
  50%     { transform: translateY(-10px); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.blob-anim  { animation: blob 10s infinite alternate cubic-bezier(.4,0,.2,1); }
.blob-anim2 { animation: blob 10s 2s infinite alternate cubic-bezier(.4,0,.2,1); }
.fade-up    { animation: fadeUp .45s ease both; }
.anim-pulse { animation: pulse 2s infinite; }
.anim-float { animation: float 3s ease-in-out infinite; }
.anim-spin  { animation: spin 1.2s linear infinite; }

/* ── Ambient background blobs ──────────────────────────────── */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.bg-blobs::before,
.bg-blobs::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}
.bg-blobs::before {
  top: -25%; left: -25%;
  width: 80vw; height: 80vw;
  background: var(--blob-1);
  animation: blob 10s infinite alternate cubic-bezier(.4,0,.2,1);
}
.bg-blobs::after {
  bottom: -25%; right: -25%;
  width: 70vw; height: 70vw;
  background: var(--blob-2);
  animation: blob 10s 2s infinite alternate cubic-bezier(.4,0,.2,1);
}
/* Red variant for error page */
.bg-blobs.danger::before { background: rgba(127,29,29,0.20); }
.bg-blobs.danger::after  { background: rgba(49,46,129,0.20); }

/* ── Layout ────────────────────────────────────────────────── */
.page-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 3rem 1.5rem;
}
.page-center {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* ── Branding ──────────────────────────────────────────────── */
.brand-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--color-accent-label);
  margin-bottom: .75rem;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 300;
  line-height: 1;
}
.footer-note {
  font-size: 10px;
  color: var(--color-text-faint);
  letter-spacing: .25em;
  text-transform: uppercase;
  text-align: center;
}

/* ── Form elements ─────────────────────────────────────────── */
.input-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: .5rem;
  margin-left: .25rem;
}
.input-field {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: .15em;
  color: var(--color-text);
  outline: none;
  transition: background .3s, border-color .3s, box-shadow .3s;
  appearance: none;
}
.input-field::placeholder { color: rgba(255,255,255,0.10); }
.input-field:focus {
  background: rgba(255,255,255,0.08);
  border-color: var(--color-accent);
  box-shadow: 0 0 20px rgba(45,212,191,.15);
}
.input-field:disabled { opacity: .4; cursor: not-allowed; }
.input-counter {
  text-align: right;
  font-size: 11px;
  color: var(--color-text-faint);
  margin-top: .25rem;
  margin-right: .25rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform .15s, opacity .15s, background .2s;
}
.btn:active:not(:disabled) { transform: scale(.95); }

.btn-primary {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-full);
  background: #ffffff;
  color: #000000;
  font-size: .875rem;
}
.btn-primary:hover:not(:disabled) { background: #ccfbf1; transform: scale(1.02); }
.btn-primary:disabled {
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.25);
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  padding: .75rem 1.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-size: .875rem;
}
.btn-ghost:hover { background: var(--color-surface-hover); }

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}
.btn-icon:active { transform: scale(.9); }

/* ── Alert ─────────────────────────────────────────────────── */
.alert-error {
  padding: .75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger);
  font-size: .875rem;
  margin-bottom: 1.5rem;
}

/* ── Menu cards ────────────────────────────────────────────── */
.card {
  display: block;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--color-text);
  transition: background .2s, transform .15s;
  margin-bottom: 1rem;
}
.card:active { transform: scale(.97); background: var(--color-surface-hover); }
.card-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon.teal {
  background: var(--color-accent-dim);
  border: 1px solid rgba(45,212,191,.20);
}
.card-icon.indigo {
  background: var(--color-indigo-dim);
  border: 1px solid var(--color-indigo-border);
}
.card-body  { flex: 1; }
.card-title { font-size: 1.05rem; font-weight: 500; margin-bottom: .25rem; }
.card-desc  { font-size: .875rem; color: var(--color-text-muted); line-height: 1.5; }
.card-row   { display: flex; align-items: flex-start; gap: 1rem; }
.card-arrow { margin-top: .25rem; color: var(--color-text-faint); }

/* ── Inner page header ─────────────────────────────────────── */
.inner-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.inner-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.inner-header .sub { font-size: 11px; color: var(--color-text-muted); letter-spacing: .2em; text-transform: uppercase; }
.inner-header .title { font-size: .875rem; font-weight: 500; line-height: 1; margin-top: 2px; }

/* ── Status dot ────────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.20);
  transition: background .3s;
  flex-shrink: 0;
}
.status-dot.connected    { background: var(--color-success); animation: pulse 2.5s infinite; }
.status-dot.error        { background: var(--color-danger); }
.status-dot.reconnecting { background: #fbbf24; }

/* ── Chat messages ─────────────────────────────────────────── */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 0;
}
.msg-user {
  align-self: flex-end;
  max-width: 80%;
  background: #ffffff;
  color: #000000;
  border-radius: var(--radius-xl);
  border-bottom-right-radius: 4px;
  padding: .625rem .875rem;
  font-size: .875rem;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  animation: fadeUp .2s ease both;
}
.msg-agent {
  align-self: flex-start;
  max-width: 80%;
  background: rgba(39,39,42,.90);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: 4px;
  padding: .625rem .875rem;
  font-size: .875rem;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  animation: fadeUp .2s ease both;
}
.msg-sys {
  align-self: center;
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px 12px;
}
.typing-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: .75rem 1rem;
}
.typing-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  animation: blink 1.3s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }

/* ── Input bar ─────────────────────────────────────────────── */
.input-bar {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  background: rgba(0,0,0,.60);
  backdrop-filter: blur(8px);
  padding: .75rem;
}
.chat-textarea {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: .625rem .875rem;
  font-size: .875rem;
  color: var(--color-text);
  outline: none;
  resize: none;
  line-height: 1.5;
  max-height: 96px;
  transition: border-color .15s, background .15s;
  font-family: var(--font-sans);
}
.chat-textarea::placeholder { color: var(--color-text-faint); }
.chat-textarea:focus { border-color: rgba(255,255,255,.25); background: var(--color-surface-hover); }
.chat-textarea:disabled { opacity: .4; cursor: not-allowed; }

.send-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-accent);
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: opacity .15s, transform .1s;
}
.send-btn:disabled { opacity: .30; cursor: not-allowed; }
.send-btn:active:not(:disabled) { transform: scale(.88); }

/* ── Mode toggle ───────────────────────────────────────────── */
.mode-toggle { display: flex; gap: .5rem; margin-bottom: .5rem; }
.mode-btn {
  flex: 1;
  padding: .375rem 0;
  border-radius: var(--radius-full);
  border: none;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .05em;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.mode-btn.active   { background: #ffffff; color: #000000; }
.mode-btn.inactive { background: var(--color-surface); color: var(--color-text-muted); }

.cam-btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-surface);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}
.cam-btn-icon:active { transform: scale(.9); }

/* ── Voice row ─────────────────────────────────────────────── */
.voice-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.mic-btn {
  width: 64px; height: 64px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, transform .1s;
}
.mic-btn:active { transform: scale(.9); }
.mic-btn.recording { border-color: var(--color-danger); background: var(--color-danger-bg); }
.mic-status { font-size: 11px; color: var(--color-text-muted); }

/* ── Countdown ring (error page) ───────────────────────────── */
.countdown-wrap {
  position: relative;
  width: 112px; height: 112px;
  margin: 0 auto;
}
.countdown-ring { transition: stroke-dashoffset 1s linear; }
.countdown-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.countdown-num  { font-size: 2rem; font-weight: 300; font-variant-numeric: tabular-nums; }
.countdown-unit { font-size: 10px; color: var(--color-text-faint); letter-spacing: .2em; }

/* ── Camera panel ──────────────────────────────────────────── */
.camera-panel {
  position: relative;
  flex-shrink: 0;
  background: #000;
  border-bottom: 1px solid var(--color-border);
}
.camera-panel video  { width: 100%; max-height: 12rem; object-fit: cover; display: block; }
.camera-overlay {
  position: absolute;
  top: .5rem; right: .5rem;
  display: flex;
  gap: .5rem;
}
.snap-preview { position: relative; flex-shrink: 0; border-bottom: 1px solid var(--color-border); }
.snap-preview img { width: 100%; max-height: 10rem; object-fit: cover; opacity: .85; display: block; }
.snap-overlay {
  position: absolute;
  top: .5rem; right: .5rem;
  display: flex;
  gap: .5rem;
}
