/* =============================================================
   ADI Pet PMS — Component primitives (vanilla CSS)
   Used by both the design-system reference doc AND future screens
   ============================================================= */

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--button-h);
  padding: 0 var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; stroke-width: 1.75; }

/* Variants */
.btn-primary {
  background: var(--teal-600);
  color: #fff;
}
.btn-primary:hover { background: var(--teal-700); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink-800);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--ink-400); }

.btn-ghost {
  background: transparent;
  color: var(--ink-700);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink-900); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(0.93); }

.btn-coral {
  background: var(--coral-500);
  color: #fff;
}
.btn-coral:hover { background: var(--coral-600); }

/* Sizes */
.btn-sm { height: var(--button-h-sm); padding: 0 var(--s-3); font-size: var(--fs-sm); }
.btn-sm .icon { width: 14px; height: 14px; }

.btn-lg { height: 48px; padding: 0 var(--s-6); font-size: var(--fs-md); }

.btn-icon { width: var(--button-h); padding: 0; }
.btn-icon.btn-sm { width: var(--button-h-sm); }

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- INPUTS ---------- */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  height: var(--input-h);
  padding: 0 var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  color: var(--ink-800);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: var(--sh-focus);
}
.textarea { height: auto; padding: var(--s-3); resize: vertical; min-height: 96px; line-height: var(--lh-base); }

.field-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink-700);
  margin-bottom: var(--s-2);
}
.field-hint {
  font-size: var(--fs-xs);
  color: var(--ink-500);
  margin-top: var(--s-2);
}
.field-error {
  font-size: var(--fs-xs);
  color: var(--danger-ink);
  margin-top: var(--s-2);
}

/* Input with icon prefix/suffix */
.input-group {
  position: relative;
}
.input-group .input { padding-left: var(--s-9); }
.input-group .input.has-suffix { padding-right: var(--s-9); }
.input-group .prefix,
.input-group .suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-500);
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}
.input-group .prefix { left: var(--s-3); }
.input-group .suffix { right: var(--s-3); pointer-events: auto; }
.input-group .icon { width: 16px; height: 16px; stroke-width: 1.75; }

/* SearchInput */
.search-input {
  position: relative;
  width: 100%;
  max-width: 480px;
}
.search-input .input { padding-left: 40px; padding-right: 76px; height: 40px; background: var(--surface-alt); }
.search-input .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-500); }
.search-input .kbd-hint {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-600);
  letter-spacing: 0.04em;
}
.search-input .clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  width: 24px; height: 24px;
  align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-500);
  border-radius: var(--r-full);
}
.search-input .clear-btn:hover { background: var(--surface-hover); color: var(--ink-800); }
.search-input[data-has-value="true"] .clear-btn { display: inline-flex; }
.search-input[data-has-value="true"] .kbd-hint { display: none; }

/* ---------- CARD ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: var(--card-pad); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-5) var(--card-pad);
  border-bottom: 1px solid var(--divider);
}
.card-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--ink-900); margin: 0; white-space: nowrap; }
.card-sub { font-size: var(--fs-sm); color: var(--ink-600); }
.card-body { padding: var(--card-pad); }
.card-foot {
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-4) var(--card-pad);
  border-top: 1px solid var(--divider);
  background: var(--surface-alt);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ---------- AVATARS ---------- */
.pet-avatar {
  display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--teal-100);
  color: var(--teal-700);
  flex-shrink: 0;
  position: relative;
  border: 1.5px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.pet-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pet-avatar .icon { width: 60%; height: 60%; stroke-width: 1.5; }
.pet-avatar.xs { width: 24px; height: 24px; }
.pet-avatar.sm { width: 32px; height: 32px; }
.pet-avatar.md { width: 40px; height: 40px; }
.pet-avatar.lg { width: 56px; height: 56px; }
.pet-avatar.xl { width: 96px; height: 96px; }

.client-avatar {
  display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--teal-tint);
  color: var(--teal-800);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  letter-spacing: var(--ls-wide);
  flex-shrink: 0;
}
.client-avatar.xs { width: 24px; height: 24px; font-size: 9px; }
.client-avatar.sm { width: 32px; height: 32px; font-size: 11px; }
.client-avatar.md { width: 40px; height: 40px; font-size: 13px; }
.client-avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.client-avatar.xl { width: 96px; height: 96px; font-size: 28px; }

/* ---------- STATUS PILL ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.pill-booked     { background: var(--status-booked-tint);     color: var(--status-booked-ink); }
.pill-booked .dot{ background: var(--status-booked); }
.pill-confirmed  { background: var(--status-confirmed-tint);  color: var(--status-confirmed-ink); }
.pill-confirmed .dot{ background: var(--status-confirmed); }
.pill-arrived    { background: var(--status-arrived-tint);    color: var(--status-arrived-ink); }
.pill-arrived .dot{ background: var(--status-arrived); }
.pill-inconsult  { background: var(--status-inconsult-tint);  color: var(--status-inconsult-ink); }
.pill-inconsult .dot{ background: var(--status-inconsult); }
.pill-complete   { background: var(--status-complete-tint);   color: var(--status-complete-ink); }
.pill-complete .dot{ background: var(--status-complete); }
.pill-noshow     { background: var(--status-noshow-tint);     color: var(--status-noshow-ink); }
.pill-noshow .dot{ background: var(--status-noshow); }
.pill-cancelled  { background: var(--status-cancelled-tint);  color: var(--status-cancelled-ink); }
.pill-cancelled .dot{ background: var(--status-cancelled); }

/* Filter chip variant */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 10px 6px 12px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink-700);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}
.chip:hover { border-color: var(--ink-400); background: var(--surface-hover); }
.chip[data-active="true"] {
  background: var(--teal-tint);
  border-color: var(--teal-500);
  color: var(--teal-800);
}
.chip .dismiss {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: var(--r-full);
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
}
.chip .dismiss:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.chip .icon { width: 12px; height: 12px; stroke-width: 2; }

/* ---------- KPI CARD ---------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--card-pad);
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.kpi-label { font-size: var(--fs-sm); color: var(--ink-600); font-weight: var(--fw-semibold); }
.kpi-value {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-bold);
  color: var(--ink-900);
  letter-spacing: var(--ls-tight);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 6px;
}
.kpi-value .unit { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--ink-600); }
.kpi-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
}
.kpi-trend.up { color: var(--success-ink); }
.kpi-trend.down { color: var(--danger-ink); }
.kpi-trend.flat { color: var(--ink-500); }
.kpi-trend .icon { width: 14px; height: 14px; stroke-width: 2; }
.kpi-spark { height: 32px; width: 100%; margin-top: var(--s-2); }

/* ---------- TABLE ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
  background: var(--surface);
}
.tbl thead th {
  position: sticky; top: 0;
  background: var(--surface-alt);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--ink-600);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.tbl thead th:hover { color: var(--ink-800); }
.tbl thead th .sort-ind {
  display: inline-flex; vertical-align: middle; margin-left: 4px;
  width: 12px; height: 12px;
}
.tbl tbody td {
  padding: var(--s-3) var(--s-4);
  height: var(--row-h);
  border-bottom: 1px solid var(--divider);
  color: var(--ink-800);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tbl tbody td.wrap { white-space: normal; }
.tbl tbody tr:hover td { background: var(--surface-hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .actions .btn-icon { width: 32px; height: 32px; }
.tbl .actions .btn-icon .icon { width: 16px; height: 16px; }

/* ---------- TIMELINE ---------- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border);
}
.timeline-entry { position: relative; padding-bottom: var(--s-6); }
.timeline-entry::before {
  content: ""; position: absolute; left: -22px; top: 4px;
  width: 10px; height: 10px;
  background: var(--surface);
  border: 2px solid var(--teal-500);
  border-radius: 50%;
}
.timeline-entry .ts {
  display: block;
  font-size: var(--fs-xs); color: var(--ink-500);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}
.timeline-entry .body { font-size: var(--fs-base); color: var(--ink-800); }
.timeline-entry .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- EMPTY STATE ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: var(--s-9) var(--s-6);
  color: var(--ink-700);
}
.empty .empty-illus { width: 96px; height: 96px; color: var(--teal-500); margin-bottom: var(--s-4); }
.empty .empty-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--ink-900); margin: 0 0 var(--s-2); }
.empty .empty-body { font-size: var(--fs-base); color: var(--ink-600); max-width: 360px; margin: 0 0 var(--s-5); line-height: var(--lh-relax); }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 54, 56, 0.36);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-6);
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}
.modal-head { padding: var(--s-6) var(--s-6) var(--s-3); }
.modal-title { margin: 0 0 var(--s-2); font-size: var(--fs-xl); font-weight: var(--fw-semibold); color: var(--ink-900); }
.modal-body { padding: 0 var(--s-6) var(--s-5); color: var(--ink-700); font-size: var(--fs-base); line-height: var(--lh-relax); }
.modal-foot {
  display: flex; gap: var(--s-2); justify-content: flex-end;
  padding: var(--s-4) var(--s-6);
  background: var(--surface-alt);
  border-top: 1px solid var(--divider);
}

/* ---------- BRANCH SWITCHER (top bar dropdown) ---------- */
.branch-switcher {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 40px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink-800);
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
}
.branch-switcher > span { white-space: nowrap; }
.branch-switcher:hover { border-color: var(--teal-500); background: var(--teal-50); }
.branch-switcher .pin { color: var(--teal-600); }
.branch-switcher .icon { width: 16px; height: 16px; stroke-width: 1.75; }
.branch-switcher .caret { color: var(--ink-500); }

/* ---------- NOTIFICATION BELL ---------- */
.bell-btn {
  position: relative;
  width: 40px; height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink-700);
  transition: all var(--dur) var(--ease);
}
.bell-btn:hover { background: var(--surface-hover); color: var(--ink-900); }
.bell-btn .icon { width: 18px; height: 18px; stroke-width: 1.75; }
.bell-btn .dot {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px;
  background: var(--danger);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

/* ---------- PET CARD ---------- */
.pet-card {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: all var(--dur) var(--ease);
}
.pet-card:hover { border-color: var(--teal-300); box-shadow: var(--sh-md); }
.pet-card .pet-info { flex: 1; min-width: 0; }
.pet-card .pet-name { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--ink-900); margin: 0; }
.pet-card .pet-meta { font-size: var(--fs-sm); color: var(--ink-600); margin: 2px 0 0; }
.pet-card .pet-owner { font-size: var(--fs-xs); color: var(--teal-700); text-decoration: none; font-weight: var(--fw-semibold); }
.pet-card .pet-owner:hover { text-decoration: underline; }

/* ---------- RICH TEXT EDITOR ---------- */
.rte {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.rte-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-alt);
  flex-wrap: wrap;
}
.rte-toolbar .tool {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: none; background: transparent; border-radius: var(--r-sm);
  cursor: pointer; color: var(--ink-700);
  transition: background var(--dur) var(--ease);
}
.rte-toolbar .tool:hover { background: var(--surface-hover); color: var(--ink-900); }
.rte-toolbar .tool[data-active="true"] { background: var(--teal-tint); color: var(--teal-800); }
.rte-toolbar .tool .icon { width: 16px; height: 16px; stroke-width: 1.75; }
.rte-toolbar .divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.rte-toolbar .tool-group { display: inline-flex; }
.rte-toolbar .template-dd {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 10px; height: 30px;
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--ink-700);
  cursor: pointer;
}
.rte-toolbar .template-dd:hover { border-color: var(--teal-500); color: var(--teal-700); }
.rte-content {
  min-height: 120px;
  padding: var(--s-4);
  font-size: var(--fs-base);
  line-height: var(--lh-relax);
  color: var(--ink-800);
}

/* ---------- KBD ---------- */
.kbd {
  display: inline-flex; align-items: center;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  color: var(--ink-700);
}

/* ---------- TOOLTIP-LIKE meta ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background: var(--ink-100);
  color: var(--ink-700);
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.tag-teal { background: var(--teal-tint); color: var(--teal-800); }
.tag-coral { background: var(--coral-200); color: var(--coral-700); }

/* ---------- APP SHELL (sidebar + topbar) ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.app-shell.collapsed { grid-template-columns: var(--sidebar-collapsed-w) 1fr; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--s-2);
  height: var(--topbar-h);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--divider);
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  letter-spacing: var(--ls-tight);
  color: var(--teal-700);
}
.sidebar-brand .brandmark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--teal-600); color: #fff;
  border-radius: var(--r-md);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  letter-spacing: 0;
}
.sidebar-nav { flex: 1; padding: var(--s-3); overflow-y: auto; }
.nav-section {
  font-size: 10px;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  color: var(--ink-400);
  padding: var(--s-3) var(--s-3) var(--s-2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px var(--s-3);
  border-radius: var(--r-md);
  color: var(--ink-700);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}
.nav-item > span { min-width: 0; }
.nav-item:hover { background: var(--surface-hover); color: var(--ink-900); }
.nav-item .icon { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; color: var(--ink-500); }
.nav-item[data-active="true"] {
  background: var(--teal-tint);
  color: var(--teal-800);
}
.nav-item[data-active="true"] .icon { color: var(--teal-700); }
.nav-item[data-active="true"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--teal-600);
}
.nav-sub { padding-left: var(--s-7); }
.nav-sub .nav-item { font-size: var(--fs-sm); padding: 6px var(--s-3); font-weight: var(--fw-medium); }

.topbar {
  display: flex; align-items: center; gap: var(--s-4);
  height: var(--topbar-h);
  padding: 0 var(--content-pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }

.content {
  padding: var(--content-pad);
}
