/**
 * CareLoop web app - the /app shell.
 *
 * Same tokens as the prototype and the phone app, so the three clients read as
 * one product.
 *
 * @author Fahad Ali Khan
 * @link   https://www.fiverr.com/fahadalikhan814
 */

:root {
  --cl-bg: #f3f2ec;
  --cl-surface: #ffffff;
  --cl-surface-2: #f7f6f0;
  --cl-ink: #20281f;
  --cl-muted: #5e655b;
  --cl-faint: #6f7669;
  --cl-line: #e5e3d8;
  --cl-line-2: #edebe1;
  --cl-brand: #206b4e;
  --cl-brand-deep: #174e39;
  --cl-brand-tint: #e6f0ea;
  --cl-accent: #c25c38;
  --cl-accent-tint: #fbeae3;
  --cl-ok: #2e7d54;
  --cl-ok-tint: #e4f0e9;
  --cl-warn: #96631d;
  --cl-warn-tint: #f8efe0;
  --cl-danger: #a63a27;
  --cl-danger-tint: #f9e8e4;
  --cl-shadow: 0 1px 2px rgba(24,28,24,.04), 0 10px 30px rgba(24,28,24,.07);
  --cl-radius: 14px;
  --cl-radius-sm: 10px;
  --cl-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --cl-serif: 'Instrument Serif', Georgia, serif;
  --cl-urdu: 'Noto Nastaliq Urdu', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--cl-bg); color: var(--cl-ink); font-family: var(--cl-sans); font-size: 16px; line-height: 1.5; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cl-brand); }

/* ---- shared atoms ---- */
.cl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--cl-brand); color: #fff; border: 0; border-radius: 999px;
  padding: 11px 22px; font-weight: 600; font-size: 15px;
}
.cl-btn:hover { background: var(--cl-brand-deep); }
.cl-btn:disabled { opacity: .55; cursor: default; }
.cl-btn--ghost { background: transparent; color: var(--cl-brand); border: 1.5px solid var(--cl-brand); }
.cl-btn--ghost:hover { background: var(--cl-brand-tint); }
.cl-btn--danger { background: var(--cl-danger); }
.cl-btn--sm { padding: 7px 14px; font-size: 14px; }
.cl-field { margin: 0 0 16px; }
.cl-field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--cl-muted); }
.cl-field input, .cl-field select, .cl-field textarea {
  width: 100%; background: var(--cl-surface); border: 1.5px solid var(--cl-line);
  border-radius: var(--cl-radius-sm); padding: 11px 14px; font-size: 16px;
}
.cl-field input:focus, .cl-field select:focus, .cl-field textarea:focus { outline: 2px solid var(--cl-brand); border-color: var(--cl-brand); }
.cl-help { font-size: 13px; color: var(--cl-faint); margin-top: 5px; }
.cl-card {
  background: var(--cl-surface); border: 1px solid var(--cl-line);
  border-radius: var(--cl-radius); padding: 20px; box-shadow: var(--cl-shadow); margin: 0 0 16px;
}
.cl-card h2 { font-family: var(--cl-serif); font-weight: 400; font-size: 1.35rem; margin: 0 0 12px; }
.cl-chip {
  display: inline-block; border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 600;
  background: var(--cl-surface-2); color: var(--cl-muted); border: 1px solid var(--cl-line);
}
.cl-chip--ok { background: var(--cl-ok-tint); color: var(--cl-ok); border-color: transparent; }
.cl-chip--warn { background: var(--cl-warn-tint); color: var(--cl-warn); border-color: transparent; }
.cl-chip--danger { background: var(--cl-danger-tint); color: var(--cl-danger); border-color: transparent; }
.cl-chip--brand { background: var(--cl-brand-tint); color: var(--cl-brand); border-color: transparent; }
.cl-badge {
  display: inline-flex; min-width: 22px; height: 22px; align-items: center; justify-content: center;
  background: var(--cl-brand); color: #fff; border-radius: 999px; font-size: 12.5px; font-weight: 700; padding: 0 7px;
}
.cl-muted { color: var(--cl-muted); }
.cl-faint { color: var(--cl-faint); font-size: 14px; }
.cl-error { color: var(--cl-danger); background: var(--cl-danger-tint); border-radius: var(--cl-radius-sm); padding: 11px 14px; margin: 0 0 14px; font-size: 15px; }
.cl-notice { color: var(--cl-danger); background: var(--cl-danger-tint); border-radius: var(--cl-radius-sm); padding: 11px 14px; margin: 0 0 14px; font-size: 14px; }
.cl-empty { text-align: center; color: var(--cl-faint); padding: 34px 20px; }
.cl-urdu { font-family: var(--cl-urdu); direction: rtl; font-size: 15px; line-height: 2; }

/* ---- login ---- */
.cl-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.cl-login__card { width: 100%; max-width: 420px; }
.cl-login__brand { font-family: var(--cl-serif); font-size: 2.1rem; margin: 0 0 4px; }
.cl-login__brand span { color: var(--cl-brand); }
.cl-login__lede { color: var(--cl-muted); margin: 0 0 22px; }
.cl-login__as { display: flex; align-items: center; gap: 7px; color: var(--cl-brand); font-weight: 600; font-size: 14.5px; margin: -6px 0 14px; }
.cl-login__pin input { font-size: 26px; letter-spacing: 10px; text-align: center; }

/* ---- app shell ---- */
.cl-shell { min-height: 100vh; display: flex; flex-direction: column; }
.cl-top {
  background: var(--cl-surface); border-bottom: 1px solid var(--cl-line);
  display: flex; align-items: center; gap: 16px; padding: 12px 22px; position: sticky; top: 0; z-index: 30;
}
.cl-top__brand { font-family: var(--cl-serif); font-size: 1.35rem; }
.cl-top__brand span { color: var(--cl-brand); }
.cl-top__who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: var(--cl-muted); }
.cl-body { display: flex; flex: 1; min-height: 0; }
.cl-nav {
  width: 220px; flex-shrink: 0; border-right: 1px solid var(--cl-line); background: var(--cl-surface);
  padding: 16px 10px; display: flex; flex-direction: column; gap: 2px;
}
.cl-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-radius: var(--cl-radius-sm); color: var(--cl-ink);
  text-decoration: none; font-weight: 500; font-size: 15px;
}
.cl-nav a:hover { background: var(--cl-surface-2); }
.cl-nav a.is-active { background: var(--cl-brand-tint); color: var(--cl-brand); font-weight: 600; }
.cl-main { flex: 1; padding: 26px; max-width: 960px; }
.cl-main h1 { font-family: var(--cl-serif); font-weight: 400; font-size: 1.7rem; margin: 0 0 18px; }
.cl-head-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 18px; }
.cl-head-row h1 { margin: 0; flex: 1; }

@media (max-width: 780px) {
  .cl-body { flex-direction: column; }
  .cl-nav { width: 100%; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--cl-line); padding: 8px 10px; }
  .cl-nav a { white-space: nowrap; }
  .cl-main { padding: 18px 16px; }
}

/* ---- lists ---- */
.cl-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--cl-surface); border: 1px solid var(--cl-line); border-radius: var(--cl-radius);
  padding: 14px 16px; margin: 0 0 10px; color: inherit; text-decoration: none;
}
.cl-row:hover { border-color: var(--cl-brand); }
.cl-row__main { flex: 1; min-width: 0; }
.cl-row__title { font-weight: 600; font-size: 16px; }
.cl-row__sub { color: var(--cl-faint); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- stats ---- */
.cl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; }
.cl-stat { background: var(--cl-surface); border: 1px solid var(--cl-line); border-radius: var(--cl-radius); padding: 16px; }
.cl-stat b { display: block; font-size: 1.7rem; font-weight: 700; }
.cl-stat span { color: var(--cl-faint); font-size: 13.5px; }

/* ---- chat ---- */
.cl-chat { display: flex; flex-direction: column; height: 420px; }
.cl-chat__scroll { flex: 1; overflow-y: auto; padding: 4px 2px; }
.cl-bubble { max-width: 78%; margin: 0 0 8px; padding: 10px 14px; border-radius: 14px; background: var(--cl-surface-2); border: 1px solid var(--cl-line); }
.cl-bubble--mine { margin-left: auto; background: var(--cl-brand-tint); border-color: var(--cl-brand); border-bottom-right-radius: 4px; }
.cl-bubble--theirs { border-bottom-left-radius: 4px; }
.cl-bubble__who { font-size: 12px; font-weight: 700; color: var(--cl-brand); margin: 0 0 2px; }
.cl-bubble__time { font-size: 11px; color: var(--cl-faint); margin-top: 3px; }
.cl-chat__composer { display: flex; gap: 8px; padding-top: 10px; }
.cl-chat__composer textarea { flex: 1; resize: none; border: 1.5px solid var(--cl-line); border-radius: var(--cl-radius-sm); padding: 10px 13px; }

/* ---- doses ---- */
.cl-dose { display: flex; align-items: center; gap: 14px; background: var(--cl-surface); border: 1px solid var(--cl-line); border-radius: var(--cl-radius); padding: 14px 16px; margin: 0 0 10px; }
.cl-dose--done { opacity: .62; }
.cl-dose__slot { width: 74px; font-weight: 700; color: var(--cl-brand); font-size: 14px; }
.cl-dose__main { flex: 1; }
.cl-dose__actions { display: flex; gap: 8px; }

/* ---- regimen builder ---- */
.cl-rx-item { border: 1px dashed var(--cl-line); border-radius: var(--cl-radius-sm); padding: 14px; margin: 0 0 12px; background: var(--cl-surface-2); }
.cl-rx-grid { display: grid; grid-template-columns: repeat(3, 70px) 1fr; gap: 10px; align-items: end; }
.cl-rx-grid .cl-field { margin: 0; }
.cl-ac { position: relative; }
.cl-ac__list { position: absolute; top: 100%; left: 0; right: 0; z-index: 40; background: var(--cl-surface); border: 1px solid var(--cl-line); border-radius: var(--cl-radius-sm); box-shadow: var(--cl-shadow); max-height: 230px; overflow-y: auto; }
.cl-ac__list button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 14px; }
.cl-ac__list button:hover { background: var(--cl-brand-tint); }

/* ---- mood + choices ---- */
.cl-choices { display: flex; flex-wrap: wrap; gap: 9px; margin: 4px 0 14px; }
.cl-choice { border: 1.5px solid var(--cl-line); background: var(--cl-surface); border-radius: 999px; padding: 8px 16px; font-size: 14.5px; }
.cl-choice.is-on { border-color: var(--cl-brand); background: var(--cl-brand-tint); color: var(--cl-brand); font-weight: 600; }

/* ---- report ---- */
.cl-pct { font-size: 3.2rem; font-weight: 700; line-height: 1.1; }
.cl-pct--good { color: var(--cl-ok); }
.cl-pct--fair { color: var(--cl-warn); }
.cl-pct--poor { color: var(--cl-danger); }

/* ---- modal + toast ---- */
.cl-modal { position: fixed; inset: 0; background: rgba(24,28,24,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 90; }
.cl-modal__card { background: var(--cl-surface); border-radius: var(--cl-radius); box-shadow: var(--cl-shadow); width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; padding: 22px; }
.cl-modal__card h3 { font-family: var(--cl-serif); font-weight: 400; font-size: 1.35rem; margin: 0 0 14px; }
.cl-modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.cl-pin-big { font-size: 2.7rem; letter-spacing: 12px; font-weight: 700; text-align: center; margin: 10px 0; }
.cl-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--cl-ink); color: #fff; border-radius: 999px; padding: 11px 22px; font-size: 14.5px; z-index: 99; box-shadow: var(--cl-shadow); }
