/* ============================================================
   Roni's Health Tracker — Components
   Buttons, cards, inputs, chips, modals, toasts, checkboxes.
   ============================================================ */

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--pad-card);
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 12px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--r-control);
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  transition: filter var(--t-fast), border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.btn-primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #241D2B; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .btn-primary { color: #241D2B; }
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: var(--surface);
}
.btn-ghost:hover { border-color: var(--accent-soft); color: var(--accent); }
.btn-danger-ghost { border: 1.5px solid var(--border); color: var(--rose); background: var(--surface); }
.btn-danger-ghost:hover { border-color: var(--rose); }
.btn-sm { padding: 7px 14px; min-height: 36px; font-size: 13.5px; }
.linkbtn {
  color: var(--note);
  font-size: 13.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.iconbtn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  transition: color var(--t-fast), border-color var(--t-fast);
}
.iconbtn:hover { border-color: var(--accent-soft); color: var(--accent); }
.iconbtn svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--pink-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: var(--r-chip);
}
.chip-plain { background: var(--surface-soft); color: var(--text-soft); letter-spacing: .4px; text-transform: none; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-control);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  min-height: 44px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 64px; resize: vertical; }
.field .big { font-size: 30px; font-family: var(--serif); text-align: center; }
.frow { display: flex; gap: 10px; }
.frow .field { flex: 1; }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14.5px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 96px;
  min-height: 48px;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg button .t { font-size: 11px; color: var(--text-soft); opacity: .8; }
.seg button.active { background: var(--lavender); color: #fff; font-weight: 600; }
.seg button.active .t { color: rgba(255, 255, 255, .85); opacity: 1; }
:root[data-theme="dark"] .seg button.active { color: #241D2B; }
:root[data-theme="dark"] .seg button.active .t { color: #241D2B; opacity: .75; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .seg button.active { color: #241D2B; }
  :root[data-theme="system"] .seg button.active .t { color: #241D2B; opacity: .75; }
}

/* ---------- Medication checklist rows ---------- */
.medrow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-radius: 14px;
  transition: background var(--t-fast);
}
.medrow:hover { background: var(--surface-soft); }
.medrow .info { flex: 1; min-width: 0; }
.medrow .name { font-size: 16px; font-weight: 600; }
.medrow .dose { font-size: 13.5px; color: var(--text-soft); }
.medrow .hint { font-size: 12.5px; color: var(--note); margin-top: 2px; }

.cbx {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  background: var(--surface);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.cbx svg {
  width: 18px; height: 18px;
  stroke: #fff; stroke-width: 2.6; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transform: scale(.5);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
:root[data-theme="dark"] .cbx svg { stroke: #241D2B; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .cbx svg { stroke: #241D2B; } }

.medrow.done .cbx { background: var(--success); border-color: var(--success); }
.medrow.done .cbx svg { opacity: 1; transform: scale(1); }
.medrow.done .name {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-color: var(--border);
  text-decoration-thickness: 1.5px;
}
.medrow.skipped { opacity: .8; }
.medrow.skipped .name::after {
  content: "Skipped";
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--rose);
  margin-left: 10px;
  text-decoration: none;
  display: inline-block;
}
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }
.medrow.pop .cbx { animation: pop .28s ease; }

.skipbtn {
  font-size: 12px;
  color: var(--text-soft);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--r-chip);
  min-height: 32px;
  flex: none;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.skipbtn:hover { color: var(--rose); border-color: var(--rose); }
.skipbtn.active { color: var(--rose); border-color: var(--rose); background: var(--pink-soft); }

/* ---------- Medication timing status (docs/MEDICATIONS.md §8) ----------
 * Late vs on-time is carried by WORDS, never color alone. The status area
 * doubles as the entry-editor affordance once an entry exists. */
.medstatus {
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 10px;
  min-height: 44px;
  text-align: right;
  cursor: pointer;
  flex: none;
  max-width: 48%;
  font: inherit;
}
.medstatus[disabled] { cursor: default; }
.medstatus:not([disabled]):hover { background: var(--surface-soft); }

.tstat { font-size: 12.5px; color: var(--text-soft); line-height: 1.35; }
.tstat .lgm { color: var(--success); margin-right: 4px; font-weight: 700; }
.tstat.late { color: var(--text); }
.tstat.late .lgm { color: var(--warn); }
.tstat.skip { color: var(--rose); }
.tstat.pendinglate, .tstat.sched { color: var(--note); }
.tsub { display: block; font-size: 11.5px; color: var(--note); }

/* Phones: status line drops below the name/dose so timing stays readable. */
@media (max-width: 560px) {
  .medrow { flex-wrap: wrap; }
  .medrow .cbx { order: 1; }
  .medrow .info { order: 2; flex: 1 1 0; min-width: 0; }
  .medrow .skipbtn { order: 3; margin-left: auto; }
  .medstatus {
    order: 5;
    flex: 1 1 100%;
    max-width: none;
    text-align: left;
    padding: 2px 8px 2px 54px;
    min-height: 32px;
  }
}

/* ---------- Progress bar ---------- */
.planbar { height: 8px; border-radius: var(--r-chip); background: var(--surface-soft); overflow: hidden; }
.planbar i {
  display: block;
  height: 100%;
  border-radius: var(--r-chip);
  background: linear-gradient(90deg, var(--lavender), var(--rose));
  transition: width var(--t-med);
}

/* ---------- Modal sheet ---------- */
.backdrop {
  position: fixed; inset: 0;
  background: var(--backdrop);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.backdrop.open { display: grid; }
.sheet {
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lift);
  width: min(460px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 26px 26px 22px;
}
.sheet h3 { font-family: var(--serif); font-size: 23px; font-weight: 500; margin-bottom: 4px; }
.sheet .sub { font-size: 13px; color: var(--text-soft); margin-bottom: 18px; }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--heading);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: var(--r-chip);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med), transform var(--t-med);
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Empty states ---------- */
.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.6;
}
.empty .big { font-family: var(--serif); font-size: 22px; color: var(--heading); margin-bottom: 6px; font-style: italic; }
