/* ==========================================================================
   CareMetrix — Reusable UI components
   ========================================================================== */

/* ---------------------------------------------------------- Page header -- */

.page { display: flex; flex-direction: column; gap: 22px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 8px;
}
.breadcrumb span:last-child { color: var(--brand-purple); }
.breadcrumb .sep { color: var(--text-3); opacity: .6; }

.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.4px;
}
.page-subtitle { color: var(--text-2); margin-top: 6px; max-width: 720px; }

.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* -------------------------------------------------------------- Buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  padding: 8px 14px;
  border-radius: var(--r-btn);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all .2s ease;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--shadow-grad);
}
.btn--primary:hover { box-shadow: 0 12px 26px -6px rgba(158, 92, 190, .56); }

.btn--pink { background: var(--grad-pink); color: #fff; box-shadow: 0 10px 24px rgba(192, 38, 211, .26); }

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border-strong);
}
.btn--ghost:hover { border-color: var(--brand-violet); color: var(--brand-purple); }

.btn--soft { background: var(--violet-bg); color: var(--brand-purple); }
.btn--soft:hover { background: #E4DBFB; }

.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--icon { padding: 8px; }

/* ---------------------------------------------------------------- Cards -- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card__body { padding: 22px 24px; }
.card__foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.card--flush .card__body { padding: 0; }

.card__link {
  color: var(--text-3);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-xs);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.card__link:hover { background: var(--violet-bg); color: var(--brand-purple); }

/* ----------------------------------------------------------- Stat cards -- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat__top { display: flex; align-items: flex-start; gap: 16px; }
.stat__icon {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--grad-purple);
  box-shadow: var(--shadow-brand);
}
.stat__icon--pink   { background: var(--grad-pink);   box-shadow: 0 10px 22px rgba(192, 38, 211, .26); }
.stat__icon--orange { background: var(--grad-orange); box-shadow: 0 10px 22px rgba(251, 113, 133, .26); }
.stat__icon--violet { background: var(--grad-violet); box-shadow: 0 10px 22px rgba(124, 58, 237, .26); }

.stat__value { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.stat__label { color: var(--text-2); font-weight: 600; font-size: 13.5px; margin-top: 2px; }
.stat__meta { display: flex; align-items: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.stat__out {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--text-3);
  opacity: .7;
  transition: color .16s var(--ease);
}
.stat__out:hover { color: var(--brand-purple); opacity: 1; }

.dot-meta { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot--green { background: var(--green-dot); }
.dot--amber { background: var(--amber-dot); }
.dot--red   { background: var(--red-dot); }
.dot--blue  { background: var(--blue-dot); }
.dot--violet{ background: var(--violet-dot); }

/* --------------------------------------------------------------- Badges -- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  background: var(--slate-bg);
  color: var(--slate);
  white-space: nowrap;
}
.badge--green  { background: var(--green-bg);  color: var(--green); }
.badge--amber  { background: var(--amber-bg);  color: var(--amber); }
.badge--red    { background: var(--red-bg);    color: var(--red); }
.badge--blue   { background: var(--blue-bg);   color: var(--blue); }
.badge--violet { background: var(--violet-bg); color: var(--violet); }
.badge--outline { background: transparent; border: 1.5px solid var(--border-strong); color: var(--text-2); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

/* --------------------------------------------------------------- Toolbar -- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.toolbar__search { position: relative; flex: 1; min-width: 220px; display: flex; align-items: center; }
.toolbar__search svg { position: absolute; left: 14px; color: var(--text-3); pointer-events: none; }
.toolbar__search input {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 8px 12px 8px 38px;
  border: 1.5px solid var(--form-border);
  border-radius: var(--form-radius);
  background: var(--form-bg);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.toolbar__search input:focus {
  border-color: var(--form-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--form-focus-ring);
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }

/* Zero-specificity base for anything typed into. `:where()` contributes no
   specificity, so every component class below still wins without !important.
   Note `input[type=search]` is deliberately absent — the header and toolbar
   search fields style themselves. */
:where(
  input[type="text"], input[type="email"], input[type="password"],
  input[type="tel"], input[type="url"], input[type="number"],
  input[type="date"], input[type="datetime-local"], input[type="month"],
  input[type="week"], input[type="time"], input:not([type]),
  select, textarea
),
.form-input, .form-select, .form-textarea {
  font-size: 12px;
  font-family: inherit;
  color: var(--form-text);
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--form-border);
  border-radius: var(--form-radius);
  padding: 8px 10px;
  background: var(--form-bg);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

/* The standard field. */
.sf-input, .select, .input, .textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  border: 1.5px solid var(--form-border);
  border-radius: var(--form-radius);
  padding: 8px 12px;
  background: var(--form-bg);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.sf-input:focus, .select:focus, .input:focus, .textarea:focus,
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--form-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--form-focus-ring);
}

.sf-input[aria-invalid="true"],
.form-input[aria-invalid="true"],
.form-select[aria-invalid="true"],
.form-textarea[aria-invalid="true"] {
  border-color: var(--form-invalid);
  background: var(--form-invalid-bg);
}

.textarea { resize: vertical; min-height: 96px; }

/* Filter selects sit inline in a toolbar, so they size to content. */
.select {
  width: auto;
  min-width: 150px;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239C95AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ---------------------------------------------------------------- Table -- */

.table-wrap { width: 100%; overflow-x: auto; }

.commonstyletabletwo {
  width: 100%;
  min-width: var(--commontable2-min-width);
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  font-size: 13px;
  background: #fff;
}

.commonstyletabletwo thead th {
  padding: clamp(10px, 1.1vw, 14px);
  background: var(--commontable2-header-bg);
  color: #393746;
  font-size: clamp(11px, .85vw, 12px);
  font-weight: 800;
  text-align: left;
  vertical-align: middle;
  letter-spacing: .03em;
  white-space: nowrap;
  border-bottom: 1px solid var(--commontable2-cell-border);
  border-right: 1px solid #e7e0f0;
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
}
.commonstyletabletwo thead th:last-child { border-right: 0; }
.commonstyletabletwo thead th:has(.commonstyletabletwo-sort-icon) { cursor: pointer; }

.commonstyletabletwo tbody td {
  padding: clamp(10px, 1.1vw, 14px);
  vertical-align: middle;
  color: var(--text-2);
  border-bottom: 1px solid var(--commontable2-cell-border);
  border-right: 1px solid #e7e0f0;
}
.commonstyletabletwo tbody td:last-child { border-right: 0; }
.commonstyletabletwo tbody tr { transition: background .14s var(--ease); }
.commonstyletabletwo tbody tr:hover { background: var(--surface-2); }
.commonstyletabletwo tbody tr:last-child td { border-bottom: 0; }

.commonstyletabletwo .t-strong { color: var(--text); font-weight: 700; }
.commonstyletabletwo .t-right { text-align: right; }
.commonstyletabletwo .t-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

.rt-table__sno { width: 64px; }

/* ----------------------------------------------------------- Pagination -- */

.pagination { display: flex; align-items: center; gap: 6px; }
.pagination button {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-xs);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-2);
  border: 1.5px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.pagination button:hover { background: var(--surface-3); color: var(--text); }
.pagination button.is-active { background: var(--grad-purple); color: #fff; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ----------------------------------------------------------------- Tabs -- */

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.tabs button {
  height: 36px;
  padding: 0 16px;
  border-radius: var(--r-xs);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button.is-active { background: var(--surface); color: var(--brand-purple); box-shadow: var(--shadow-xs); }

/* ---------------------------------------------------------- Empty state -- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--brand-violet);
  margin-bottom: 4px;
}
.empty__title { font-weight: 700; color: var(--text); font-size: 15px; }

/* -------------------------------------------------------------- Listrow -- */

.list { display: flex; flex-direction: column; }
.list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.list__row:last-child { border-bottom: 0; }
.list__title { font-weight: 700; }
.list__sub { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

/* ----------------------------------------------------------- Progress -- */

.bar { height: 10px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--grad-purple); }
.bar--pink > span { background: var(--grad-pink); }

/* ---------------------------------------------------------------- Grids -- */

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }

/* --------------------------------------------------------------- Notice -- */

.notice {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--violet-bg);
  color: var(--violet);
  font-weight: 600;
  font-size: 13.5px;
}
.notice--amber { background: var(--amber-bg); color: var(--amber); }
.notice--red   { background: var(--red-bg);   color: var(--red); }

/* ------------------------------------------------------------- Calendar -- */

.cal { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.cal__head,
.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal__head span {
  padding: 12px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.cal__cell {
  min-height: 108px;
  padding: 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal__cell:nth-child(7n) { border-right: 0; }
.cal__cell.is-muted { background: var(--surface-2); }
.cal__cell.is-today { background: var(--violet-bg); }
.cal__day { font-weight: 700; font-size: 13px; color: var(--text-2); }
.cal__cell.is-today .cal__day { color: var(--brand-purple); }
.cal__event {
  display: block;
  padding: 5px 8px;
  border-radius: var(--r-xs);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.3;
  background: var(--violet-bg);
  color: var(--violet);
}
.cal__event--pink  { background: #FCE7F3; color: #BE185D; }
.cal__event--amber { background: var(--amber-bg); color: var(--amber); }
.cal__event--blue  { background: var(--blue-bg);  color: var(--blue); }

@media (max-width: 760px) {
  .cal__cell { min-height: 78px; padding: 6px; }
  .cal__event { font-size: 10px; padding: 3px 5px; }
}

/* --------------------------------------------------------------- Drawer -- */
/* Shared slide-over used by any page that needs one. The header carries the
   brand gradient so every drawer in the product reads the same. */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 28, 60, .45);
  backdrop-filter: blur(1px);
  z-index: 100;
  display: none;
}
.overlay.show { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 760px;
  max-width: 94vw;
  z-index: 101;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .28s var(--ease);
}
.drawer.show { transform: none; }
.drawer.narrow { width: 560px; }

.drawer-header {
  position: relative;
  flex: none;
  padding: 22px 26px;
  background: var(--grad-brand);
  color: #fff;
}
.drawer-header h3 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
.drawer-header p  { margin: 0; font-size: 12.5px; opacity: .92; }

.drawer-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: #fff;
  background: rgba(255, 255, 255, .22);
  transition: background .16s var(--ease);
}
.drawer-close:hover { background: rgba(255, 255, 255, .34); }

.drawer-body { flex: 1; overflow-y: auto; padding: 22px 26px 30px; }
.drawer-footer {
  flex: none;
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------------------------------------------------------------- Toast -- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border-radius: var(--r-sm);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
