/* ==========================================================================
   DokterDietku — Components
   Buttons, cards, inputs, badges, avatars, modals, toasts, skeletons,
   tables, tabs, steppers, progress, empty/error states.
   ========================================================================== */

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0 var(--sp-5); height: 46px;
  border: 1px solid transparent; border-radius: var(--r-full);
  font-size: var(--fs-14); font-weight: var(--fw-semibold); letter-spacing: 0.01em;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--c-primary-700); color: #fff; box-shadow: var(--sh-sm); }
.btn--primary:hover { background: var(--c-primary-600); color: #fff; box-shadow: var(--sh-md); }

.btn--secondary { background: var(--c-surface); color: var(--c-primary-700); border-color: var(--c-border-strong); }
.btn--secondary:hover { border-color: var(--c-primary-600); background: var(--c-primary-50); color: var(--c-primary-700); }

.btn--ghost { background: transparent; color: var(--c-text-soft); }
.btn--ghost:hover { background: var(--c-bg-alt); color: var(--c-text); }

.btn--danger { background: var(--c-danger); color: #fff; }
.btn--danger:hover { background: #9E3232; color: #fff; }

.btn--danger-ghost { background: transparent; color: var(--c-danger); border-color: var(--c-danger-bg); }
.btn--danger-ghost:hover { background: var(--c-danger-bg); border-color: var(--c-danger); }

.btn--sm { height: 36px; padding: 0 var(--sp-4); font-size: var(--fs-13); }
.btn--lg { height: 54px; padding: 0 var(--sp-8); font-size: var(--fs-16); }
.btn--block { width: 100%; }
.btn--icon { width: 40px; height: 40px; padding: 0; border-radius: var(--r-sm); }

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

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card--pad { padding: var(--sp-6); }
.card--pad-lg { padding: var(--sp-8); }
.card--hover { transition: box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base); }
.card--hover:hover { box-shadow: var(--sh-md); transform: translateY(-2px); border-color: var(--c-border-strong); }

.card__title { font-size: var(--fs-18); font-weight: var(--fw-semibold); }
.card__subtitle { font-size: var(--fs-13); color: var(--c-text-muted); margin-top: var(--sp-1); }

/* ----------------------------------------------------------------- Inputs */

.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field__label { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--c-text-soft); }
.field__label .req { color: var(--c-danger); margin-left: 2px; }
.field__hint { font-size: var(--fs-12); color: var(--c-text-muted); }
.field__error { font-size: var(--fs-12); color: var(--c-danger); display: none; align-items: center; gap: var(--sp-1); }
.field--invalid .field__error { display: flex; }
.field--invalid .input, .field--invalid .select, .field--invalid .textarea { border-color: var(--c-danger); }

.input, .select, .textarea {
  width: 100%; height: 46px; padding: 0 var(--sp-4);
  background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  font-size: var(--fs-14); color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { height: auto; min-height: 96px; padding: var(--sp-3) var(--sp-4); resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--c-text-faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-primary-600); box-shadow: var(--sh-focus); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--c-bg-alt); color: var(--c-text-muted); cursor: not-allowed; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364767B' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--sp-4) center; padding-right: var(--sp-10);
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 52px; }
.input-group__suffix {
  position: absolute; right: var(--sp-4); font-size: var(--fs-13); color: var(--c-text-muted); pointer-events: none;
}

/* Search input with icon */
.search { position: relative; }
.search .input { padding-left: 42px; }
.search__icon { position: absolute; left: var(--sp-4); top: 50%; transform: translateY(-50%); color: var(--c-text-faint); pointer-events: none; display: flex; }

/* Choice chips (radio/checkbox pills) */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-full);
  border: 1px solid var(--c-border-strong); background: var(--c-surface);
  font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--c-text-soft);
  cursor: pointer; transition: all var(--t-fast); user-select: none;
}
.chip:hover { border-color: var(--c-primary-500); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--c-primary-50); border-color: var(--c-primary-600); color: var(--c-primary-700); }
.chip:has(input:focus-visible) { box-shadow: var(--sh-focus); }

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

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px var(--sp-3); border-radius: var(--r-full);
  font-size: var(--fs-12); font-weight: var(--fw-semibold); letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.badge--plain::before { display: none; }
.badge--success { background: var(--c-success-bg); color: var(--c-success); }
.badge--warning { background: var(--c-warning-bg); color: var(--c-warning); }
.badge--danger  { background: var(--c-danger-bg);  color: var(--c-danger); }
.badge--info    { background: var(--c-info-bg);    color: var(--c-info); }
.badge--neutral { background: var(--c-bg-alt);     color: var(--c-text-muted); }
.badge--primary { background: var(--c-primary-50); color: var(--c-primary-700); }

/* ---------------------------------------------------------------- Avatars */

.avatar {
  position: relative; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: var(--fw-semibold); color: #fff; overflow: hidden;
  background: var(--c-primary-600);
}
.avatar svg { width: 100%; height: 100%; }
.avatar--sm { width: 34px; height: 34px; font-size: var(--fs-12); }
.avatar--lg { width: 64px; height: 64px; font-size: var(--fs-20); }
.avatar--xl { width: 96px; height: 96px; font-size: var(--fs-30); }
.avatar__status {
  position: absolute; right: 0; bottom: 0; width: 12px; height: 12px;
  border-radius: var(--r-full); border: 2.5px solid var(--c-surface); background: var(--c-success);
}
.avatar__status--busy { background: var(--c-accent-500); }
.avatar__status--off { background: var(--c-text-faint); }

/* ------------------------------------------------------------------ Modal */

.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: rgba(15, 30, 28, 0.45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  opacity: 0; transition: opacity var(--t-base);
}
.modal-overlay.is-open { opacity: 1; }
.modal {
  width: 100%; max-width: 520px; max-height: min(88vh, 900px);
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--sh-xl);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(14px) scale(0.985); transition: transform var(--t-base) var(--ease-out);
}
.modal-overlay.is-open .modal { transform: none; }
.modal--lg { max-width: 720px; }
.modal__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
}
.modal__title { font-size: var(--fs-18); font-weight: var(--fw-semibold); }
.modal__close {
  width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--c-text-muted); transition: background var(--t-fast), color var(--t-fast);
}
.modal__close:hover { background: var(--c-bg-alt); color: var(--c-text); }
.modal__body { padding: 0 var(--sp-6) var(--sp-5); overflow-y: auto; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--c-border); background: var(--c-surface-sunk);
}

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

.toast-region {
  position: fixed; z-index: var(--z-toast);
  bottom: var(--sp-6); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%;
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--c-text); color: #fff;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); box-shadow: var(--sh-lg);
  font-size: var(--fs-14); font-weight: var(--fw-medium);
  animation: toast-in var(--t-base) var(--ease-out);
}
.toast.is-leaving { animation: toast-out var(--t-base) var(--ease-in-out) forwards; }
.toast__icon { display: flex; flex-shrink: 0; }
.toast--success .toast__icon { color: #7BD9B3; }
.toast--error .toast__icon { color: #F0A6A0; }
.toast--info .toast__icon { color: #9CC8E8; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* -------------------------------------------------------------- Skeletons */

.skeleton {
  position: relative; overflow: hidden;
  background: var(--c-bg-alt); border-radius: var(--r-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.75), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton--text { height: 14px; margin-block: 5px; }
.skeleton--title { height: 22px; width: 55%; }
.skeleton--circle { border-radius: var(--r-full); }
.skeleton--card { height: 120px; border-radius: var(--r-lg); }

/* ------------------------------------------------------------ Empty/Error */

.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--sp-12) var(--sp-6); gap: var(--sp-2);
}
.empty-state__icon {
  width: 64px; height: 64px; border-radius: var(--r-full);
  background: var(--c-primary-50); color: var(--c-primary-600);
  display: grid; place-items: center; margin-bottom: var(--sp-2);
}
.empty-state__title { font-size: var(--fs-16); font-weight: var(--fw-semibold); }
.empty-state__text { font-size: var(--fs-14); color: var(--c-text-muted); max-width: 380px; }
.empty-state .btn { margin-top: var(--sp-3); }

.error-state { /* same shell, red tint */
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--sp-12) var(--sp-6); gap: var(--sp-2);
}
.error-state__icon {
  width: 64px; height: 64px; border-radius: var(--r-full);
  background: var(--c-danger-bg); color: var(--c-danger);
  display: grid; place-items: center; margin-bottom: var(--sp-2);
}

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

.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--c-border); overflow-x: auto; }
.tabs__btn {
  position: relative; padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-14); font-weight: var(--fw-medium); color: var(--c-text-muted);
  white-space: nowrap; transition: color var(--t-fast);
}
.tabs__btn:hover { color: var(--c-text); }
.tabs__btn[aria-selected="true"] { color: var(--c-primary-700); font-weight: var(--fw-semibold); }
.tabs__btn[aria-selected="true"]::after {
  content: ""; position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: -1px;
  height: 2.5px; border-radius: var(--r-full); background: var(--c-primary-600);
}
.tabs__count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  margin-left: var(--sp-2); border-radius: var(--r-full);
  background: var(--c-bg-alt); font-size: var(--fs-11); font-weight: var(--fw-semibold); color: var(--c-text-muted);
}
.tabs__btn[aria-selected="true"] .tabs__count { background: var(--c-primary-50); color: var(--c-primary-700); }

/* --------------------------------------------------------------- Stepper */

.stepper { display: flex; align-items: center; gap: var(--sp-2); }
.stepper__item { display: flex; align-items: center; gap: var(--sp-2); }
.stepper__dot {
  width: 28px; height: 28px; border-radius: var(--r-full); flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--c-bg-alt); color: var(--c-text-muted);
  font-size: var(--fs-12); font-weight: var(--fw-semibold);
  border: 1.5px solid var(--c-border-strong); transition: all var(--t-base);
}
.stepper__item.is-active .stepper__dot { background: var(--c-primary-700); border-color: var(--c-primary-700); color: #fff; }
.stepper__item.is-done .stepper__dot { background: var(--c-primary-50); border-color: var(--c-primary-600); color: var(--c-primary-700); }
.stepper__label { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--c-text-muted); }
.stepper__item.is-active .stepper__label { color: var(--c-text); font-weight: var(--fw-semibold); }
.stepper__bar { flex: 1; min-width: 18px; height: 1.5px; background: var(--c-border-strong); border-radius: 2px; }
.stepper__item.is-done + .stepper__bar, .stepper__bar.is-done { background: var(--c-primary-500); }

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

.progress { height: 8px; border-radius: var(--r-full); background: var(--c-bg-alt); overflow: hidden; }
.progress__bar {
  height: 100%; border-radius: var(--r-full); background: var(--c-primary-600);
  transition: width var(--t-slow) var(--ease-out);
}
.progress__bar--accent { background: var(--c-accent-500); }

.progress-ring { transform: rotate(-90deg); }
.progress-ring__track { stroke: var(--c-bg-alt); }
.progress-ring__bar { stroke: var(--c-primary-600); stroke-linecap: round; transition: stroke-dashoffset var(--t-slow) var(--ease-out); }

/* ----------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); }
.table { font-size: var(--fs-14); min-width: 640px; }
.table th {
  text-align: left; padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-12); font-weight: var(--fw-semibold); letter-spacing: var(--ls-wide); text-transform: uppercase;
  color: var(--c-text-muted); background: var(--c-surface-sunk); border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--c-surface-sunk); }
.table__actions { display: flex; gap: var(--sp-1); justify-content: flex-end; }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm); display: inline-grid; place-items: center;
  color: var(--c-text-muted); transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--c-bg-alt); color: var(--c-text); }
.icon-btn--danger:hover { background: var(--c-danger-bg); color: var(--c-danger); }

/* -------------------------------------------------------------- Stat tile */

.stat {
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-5); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-xs);
}
.stat__label { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--c-text-muted); display: flex; align-items: center; gap: var(--sp-2); }
.stat__value { font-size: var(--fs-30); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); line-height: 1.1; }
.stat__value small { font-size: var(--fs-14); font-weight: var(--fw-medium); color: var(--c-text-muted); letter-spacing: 0; }
.stat__delta { font-size: var(--fs-12); font-weight: var(--fw-semibold); }
.stat__icon {
  width: 38px; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--c-primary-50); color: var(--c-primary-700);
}

/* ------------------------------------------------------------- List rows */

.list-row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.list-row:hover { border-color: var(--c-border-strong); box-shadow: var(--sh-sm); }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { font-size: var(--fs-14); font-weight: var(--fw-semibold); }
.list-row__sub { font-size: var(--fs-13); color: var(--c-text-muted); margin-top: 2px; }

/* --------------------------------------------------------------- Divider */

.divider { height: 1px; background: var(--c-border); border: none; margin: var(--sp-5) 0; }

/* ------------------------------------------------------------ Star rating */

.stars { display: inline-flex; align-items: center; gap: 2px; color: var(--c-accent-500); }
.stars svg { width: 14px; height: 14px; }

/* --------------------------------------------------------- Key-value grid */

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-4); }
.kv__item { display: flex; flex-direction: column; gap: 2px; }
.kv__label { font-size: var(--fs-12); color: var(--c-text-muted); font-weight: var(--fw-medium); }
.kv__value { font-size: var(--fs-15, 0.9375rem); font-weight: var(--fw-semibold); }

/* ------------------------------------------------------------- Page head */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head__title { font-size: var(--fs-24); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.page-head__sub { font-size: var(--fs-14); color: var(--c-text-muted); margin-top: var(--sp-1); }
.page-head__actions { display: flex; gap: var(--sp-3); align-items: center; }

/* ------------------------------------------------------------ Breadcrumbs */

.crumbs { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); color: var(--c-text-muted); margin-bottom: var(--sp-4); }
.crumbs a { color: var(--c-text-muted); font-weight: var(--fw-medium); }
.crumbs a:hover { color: var(--c-primary-700); }
.crumbs__sep { color: var(--c-text-faint); }
.crumbs [aria-current] { color: var(--c-text); font-weight: var(--fw-semibold); }

/* --------------------------------------------------------------- Tooltip */

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(2px);
  background: var(--c-text); color: #fff; font-size: var(--fs-12); font-weight: var(--fw-medium);
  padding: 5px 10px; border-radius: var(--r-xs); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast);
  z-index: var(--z-toast);
}
[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --------------------------------------------------------- Pulse (unread) */

.dot-unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--c-danger); color: #fff;
  font-size: var(--fs-11); font-weight: var(--fw-bold);
  display: inline-grid; place-items: center;
}

/* -------------------------------------------------------------- Timeline */

.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--c-border); border-radius: 2px;
}
.timeline__item { position: relative; padding-bottom: var(--sp-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  position: absolute; left: calc(-1 * var(--sp-6)); top: 4px;
  width: 16px; height: 16px; border-radius: var(--r-full);
  background: var(--c-surface); border: 2.5px solid var(--c-border-strong);
}
.timeline__item.is-done .timeline__dot { border-color: var(--c-primary-600); background: var(--c-primary-600); }
.timeline__item.is-current .timeline__dot { border-color: var(--c-primary-600); box-shadow: 0 0 0 4px var(--c-primary-100); }
.timeline__title { font-size: var(--fs-14); font-weight: var(--fw-semibold); }
.timeline__meta { font-size: var(--fs-12); color: var(--c-text-muted); margin-top: 1px; }
