/* ═══════════════════════════════════════════════════════════
   MEDIKS PWA — Shared Styles
   Used by every screen. Import with:
   <link rel="stylesheet" href="/pwa/shared.css">
   ═══════════════════════════════════════════════════════════ */

/* ── GOOGLE FONT ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── DESIGN TOKENS ───────────────────────────────────────── */
:root {
  /* Brand */
  --teal:        #00B5A3;
  --teal-dk:     #009688;
  --teal-bg:     #E6F7F5;
  --teal-mid:    rgba(0,181,163,0.15);
  --teal-bdr:    rgba(0,181,163,0.25);
  --blue:        #2563EB;
  --green:       #10B981;
  --green-bg:    #ECFDF5;
  --amber:       #F59E0B;
  --amber-bg:    #FFFBEB;
  --red:         #EF4444;
  --red-bg:      #FEF2F2;

  /* Surfaces */
  --bg:          #F4F6F9;
  --card:        #FFFFFF;
  --surface:     #F0F2F5;
  --border:      #E4E7EC;

  /* Text */
  --t1:          #0F172A;
  --t2:          #334155;
  --t3:          #64748B;
  --t4:          #94A3B8;

  /* Shadows */
  --sh-xs: 0 1px 3px rgba(0,0,0,0.06);
  --sh-sm: 0 2px 8px rgba(0,0,0,0.08);
  --sh-md: 0 4px 16px rgba(0,0,0,0.10);
  --sh-tl: 0 4px 20px rgba(0,181,163,0.22);

  /* Layout */
  --nav-h:  58px;
  --hdr-h:  60px;
  --r:      14px;
  --r-sm:   10px;
  --r-xs:    7px;
  --pad:    16px;
}

/* ── BASE ────────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--t1);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ── APP SHELL ───────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* Full-screen pages (welcome, login, etc.) */
.page {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--pad);
}
.page::-webkit-scrollbar { display: none; }

/* ── LOGO MARK ───────────────────────────────────────────── */
.logo-mark {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg, var(--teal), #00CEC0);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-tl);
}
.logo-mark svg { width: 26px; height: 26px; color: #fff; }
.logo-mark.sm { width: 36px; height: 36px; border-radius: 10px; }
.logo-mark.sm svg { width: 18px; height: 18px; }

/* ── TYPOGRAPHY ──────────────────────────────────────────── */
.page-title   { font-size: 26px; font-weight: 800; color: var(--t1); line-height: 1.2; }
.page-sub     { font-size: 14px; color: var(--t3); margin-top: 6px; line-height: 1.5; }
.label        { font-size: 13px; font-weight: 600; color: var(--t2); margin-bottom: 6px; display: block; }

/* ── FORM ELEMENTS ───────────────────────────────────────── */
.input-wrap { margin-bottom: 16px; }

.input {
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--card);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--t1);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-mid);
}
.input::placeholder { color: var(--t4); font-weight: 400; }
.input.error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }

.input-prefix {
  position: relative;
}
.input-prefix .prefix {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 15px; font-weight: 600; color: var(--t3);
  pointer-events: none;
}
.input-prefix .input { padding-left: 44px; }

.error-msg {
  font-size: 12px; color: var(--red); margin-top: 5px;
  display: flex; align-items: center; gap: 4px;
}

/* ── SELECT ──────────────────────────────────────────────── */
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--teal);
  color: #fff;
  box-shadow: var(--sh-tl);
}
.btn-primary:active { background: var(--teal-dk); }

.btn-outline {
  background: transparent;
  color: var(--teal);
  border: 1.5px solid var(--teal-bdr);
}
.btn-outline:active { background: var(--teal-bg); }

.btn-ghost {
  background: var(--surface);
  color: var(--t2);
  border: 1px solid var(--border);
}
.btn-ghost:active { background: var(--border); }

.btn svg { width: 18px; height: 18px; }

/* ── OTP INPUT ───────────────────────────────────────────── */
.otp-wrap {
  display: flex; gap: 10px; justify-content: center;
}
.otp-box {
  width: 46px; height: 54px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--card);
  text-align: center;
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  color: var(--t1);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  caret-color: var(--teal);
}
.otp-box:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-mid);
}
.otp-box.filled { border-color: var(--teal); background: var(--teal-bg); }
.otp-box.error  { border-color: var(--red);  background: var(--red-bg); }

/* ── CARD ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--pad);
  box-shadow: var(--sh-xs);
}

/* ── DIVIDER ─────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0; color: var(--t4); font-size: 12px; font-weight: 500;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── TOGGLE / CHECKBOX ───────────────────────────────────── */
.toggle-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; background: var(--surface);
  border-radius: var(--r-sm); margin-bottom: 10px;
  cursor: pointer;
}
.toggle {
  width: 44px; height: 24px; border-radius: 12px;
  background: var(--border); position: relative;
  transition: background .2s; flex-shrink: 0;
  margin-top: 1px;
  border: none; cursor: pointer;
}
.toggle::after {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--teal); }
.toggle.on::after { transform: translateX(20px); }
.toggle-text { flex: 1; }
.toggle-title { font-size: 13px; font-weight: 600; color: var(--t1); }
.toggle-sub   { font-size: 12px; color: var(--t3); margin-top: 2px; line-height: 1.4; }

/* ── BACK BUTTON ─────────────────────────────────────────── */
.back-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--t3); font-family: inherit;
  font-size: 14px; font-weight: 600;
  padding: 8px 0; margin-bottom: 8px;
  transition: color .15s;
}
.back-btn:active { color: var(--t1); }
.back-btn svg { width: 18px; height: 18px; }

/* ── STEP INDICATOR ──────────────────────────────────────── */
.steps {
  display: flex; gap: 6px; margin-bottom: 28px;
}
.step-dot {
  height: 4px; border-radius: 2px;
  background: var(--border); transition: all .3s;
  flex: 1;
}
.step-dot.done   { background: var(--teal-mid); }
.step-dot.active { background: var(--teal); flex: 2; }

/* ── TIME PICKER ROW ─────────────────────────────────────── */
.time-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.time-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.time-info { flex: 1; }
.time-label { font-size: 13px; font-weight: 700; color: var(--t1); }
.time-sub   { font-size: 11px; color: var(--t3); }
.time-inputs { display: flex; align-items: center; gap: 6px; }
.time-input {
  width: 80px; padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--card);
  font-family: inherit; font-size: 14px;
  font-weight: 700; color: var(--t1);
  text-align: center; outline: none;
  transition: border-color .15s;
}
.time-input:focus { border-color: var(--teal); }
.time-sep { font-size: 13px; color: var(--t3); font-weight: 600; }

/* ── SPINNER ─────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 10px);
  transform: translateX(-50%) translateY(10px);
  background: var(--t1); color: #fff;
  padding: 9px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--sh-md); z-index: 999;
  opacity: 0;
  transition: opacity .22s, transform .22s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap; pointer-events: none;
  max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* For pages without nav, toast sits at bottom */
.no-nav .toast {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
}

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes fadeIn   { from{opacity:0} to{opacity:1} }
@keyframes slideUp  { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideIn  { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }

.anim-fade { animation: fadeIn .3s ease both; }
.anim-up   { animation: slideUp .3s ease both; }
.anim-in   { animation: slideIn .25s ease both; }

.delay-1 { animation-delay: .06s; }
.delay-2 { animation-delay: .12s; }
.delay-3 { animation-delay: .18s; }
.delay-4 { animation-delay: .24s; }
.delay-5 { animation-delay: .30s; }

/* ── SAFE AREA ───────────────────────────────────────────── */
.safe-top    { padding-top:    env(safe-area-inset-top,    0px); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
