/* =========================================================
   SABIN BACKOFFICE — COMPONENTS
   ========================================================= */

/* ---------- ICON DEFAULT (global) ---------- */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

/* ---------- LAYOUT HELPERS ---------- */
.row     { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack   { display: flex; flex-direction: column; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow    { flex: 1; }

/* ---------- TYPOGRAPHY UTILITIES ---------- */
.t-display    { font-size: var(--fs-56); font-weight: var(--fw-medium); letter-spacing: var(--ls-tight); line-height: var(--lh-tight); }
.t-h1         { font-size: var(--fs-40); font-weight: var(--fw-semi);  letter-spacing: var(--ls-snugger); line-height: var(--lh-tight); }
.t-h2         { font-size: var(--fs-28); font-weight: var(--fw-semi);  letter-spacing: var(--ls-snugger); line-height: var(--lh-snug); }
.t-h3         { font-size: var(--fs-20); font-weight: var(--fw-semi);  line-height: var(--lh-snug); }
.t-h4         { font-size: var(--fs-16); font-weight: var(--fw-semi);  line-height: var(--lh-snug); }
.t-body       { font-size: var(--fs-15); font-weight: var(--fw-regular); line-height: var(--lh-base); }
.t-body-sm    { font-size: var(--fs-14); font-weight: var(--fw-regular); line-height: var(--lh-base); }
.t-caption    { font-size: var(--fs-12); font-weight: var(--fw-medium);  line-height: var(--lh-base); color: var(--color-text-muted); }
.t-overline   { font-size: 11px; font-weight: var(--fw-semi); letter-spacing: var(--ls-mega); text-transform: uppercase; color: var(--color-text-muted); }
.t-mono       { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.t-muted      { color: var(--color-text-muted); }
.t-subtle     { color: var(--color-text-subtle); }
.t-num        { font-variant-numeric: tabular-nums; }

/* ---------- LOGO ---------- */
.sabin-logo {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: var(--fw-bold);
  font-size: 22px;
  letter-spacing: -0.04em;
  color: var(--sabin-red);
}
.sabin-logo sup { font-size: 0.45em; font-weight: var(--fw-medium); top: -0.9em; position: relative; }
.sabin-logo--white { color: white; }
.sabin-logo--dark  { color: var(--neutral-900); }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: var(--fw-semi);
  font-size: var(--fs-14);
  letter-spacing: -0.005em;
  padding: 0 16px;
  height: 40px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: var(--neutral-100);
  color: var(--color-text);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn--primary {
  background: var(--sabin-red);
  color: var(--color-text-onbrand);
}
.btn--primary:hover { background: var(--sabin-red-700); }
.btn--primary:active { background: var(--sabin-red-800); }

.btn--secondary {
  background: var(--neutral-00);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn--secondary:hover { background: var(--neutral-50); border-color: var(--neutral-400); }

.btn--ghost {
  background: transparent;
  color: var(--color-text);
}
.btn--ghost:hover { background: var(--neutral-100); }

.btn--danger {
  background: var(--neutral-00);
  color: var(--sabin-red);
  border-color: var(--sabin-red-100);
}
.btn--danger:hover { background: var(--sabin-red-50); border-color: var(--sabin-red); }

.btn--danger-solid {
  background: var(--sabin-red);
  color: white;
}
.btn--danger-solid:hover { background: var(--sabin-red-700); }

.btn--sm { height: 32px; padding: 0 12px; font-size: var(--fs-13); }
.btn--lg { height: 48px; padding: 0 22px; font-size: var(--fs-15); }
.btn--xl { height: 56px; padding: 0 28px; font-size: var(--fs-16); }
.btn--icon { width: 40px; padding: 0; }
.btn--sm.btn--icon { width: 32px; }
.btn--lg.btn--icon { width: 48px; }

.btn--block { width: 100%; }

.btn .icon { width: 18px; height: 18px; flex: none; }
.btn--sm .icon { width: 16px; height: 16px; }

/* ---------- FORM CONTROLS ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: var(--fs-13);
  font-weight: var(--fw-semi);
  color: var(--color-text);
}
.field__label .req { color: var(--sabin-red); margin-left: 2px; }
.field__hint { font-size: var(--fs-12); color: var(--color-text-muted); }
.field__error { font-size: var(--fs-12); color: var(--sabin-red); display: flex; align-items: center; gap: 4px; }

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  color: var(--color-text);
  background: var(--neutral-00);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--neutral-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--neutral-400); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--sabin-red);
  box-shadow: var(--ring-focus);
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: var(--lh-base); }

.input--lg { height: 48px; font-size: var(--fs-15); }
.input--sm { height: 32px; font-size: var(--fs-13); padding: 0 10px; }

.input.is-error, .select.is-error, .textarea.is-error {
  border-color: var(--sabin-red);
  background: var(--sabin-red-50);
}

.input[disabled], .select[disabled], .textarea[disabled] {
  background: var(--neutral-50);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 40px; }
.input-group .input-group__icon {
  position: absolute; left: 12px; width: 18px; height: 18px;
  color: var(--neutral-500); pointer-events: none;
}
.input-group--right .input { padding-left: 14px; padding-right: 40px; }
.input-group--right .input-group__icon { left: auto; right: 12px; }

/* Select chevron */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238B8B85' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Checkbox + Radio */
.check, .radio {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: var(--fs-14); cursor: pointer; user-select: none;
}
.check input, .radio input { position: absolute; opacity: 0; pointer-events: none; }
.check__box, .radio__dot {
  width: 18px; height: 18px; flex: none;
  border: 1.5px solid var(--neutral-400);
  background: var(--neutral-00);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease-out);
}
.check__box { border-radius: 5px; }
.radio__dot { border-radius: 50%; }
.check input:checked + .check__box {
  background: var(--sabin-red); border-color: var(--sabin-red);
}
.check input:checked + .check__box::after {
  content: ""; width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'></polyline></svg>") no-repeat center / contain;
}
.radio input:checked + .radio__dot { border-color: var(--sabin-red); }
.radio input:checked + .radio__dot::after {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--sabin-red);
}
.check input:focus-visible + .check__box,
.radio input:focus-visible + .radio__dot { box-shadow: var(--ring-focus); }

/* Toggle / Switch */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: var(--fs-14); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track {
  width: 36px; height: 20px; border-radius: var(--r-pill);
  background: var(--neutral-300); position: relative;
  transition: background var(--dur-base) var(--ease-out);
}
.toggle__track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-out);
}
.toggle input:checked + .toggle__track { background: var(--sabin-red); }
.toggle input:checked + .toggle__track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle__track { box-shadow: var(--ring-focus); }

/* ---------- BADGES / CHIPS / TAGS ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  font-weight: var(--fw-semi);
  letter-spacing: 0;
  background: var(--neutral-100);
  color: var(--color-text);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--neutral { background: var(--neutral-100);   color: var(--neutral-700); }
.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-bg);  color: var(--color-danger);  }
.badge--info    { background: var(--color-info-bg);    color: var(--color-info);    }
.badge--brand   { background: var(--sabin-red-50);     color: var(--sabin-red); }
.badge--solid-brand { background: var(--sabin-red); color: white; }
.badge--mauve   { background: var(--sabin-hue-soft);   color: #6e4a4b; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 14px;
  border-radius: var(--r-pill);
  font-size: var(--fs-13); font-weight: var(--fw-medium);
  background: var(--neutral-00);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.chip:hover { background: var(--neutral-50); }
.chip.is-active {
  background: var(--neutral-900);
  color: white; border-color: var(--neutral-900);
}
.chip--brand {
  background: var(--sabin-bege);
  border-color: transparent;
  color: var(--neutral-900);
}
.chip__close {
  width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(0,0,0,.08); color: inherit;
  margin-right: -6px; margin-left: 2px;
}

/* ---------- CARD ---------- */
.card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card--raised  { box-shadow: var(--shadow-sm); border-color: transparent; }
.card--brand   { background: var(--sabin-red); color: white; border-color: transparent; border-radius: var(--r-2xl); }
.card--bege    { background: var(--sabin-bege); border-color: transparent; border-radius: var(--r-2xl); }
.card__title   { font-size: var(--fs-16); font-weight: var(--fw-semi); margin: 0 0 4px; }
.card__meta    { font-size: var(--fs-13); color: var(--color-text-muted); }

/* ---------- TABLE ---------- */
.table-wrap {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.table th, .table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}
.table thead th {
  background: var(--sabin-offwhite-2);
  font-size: var(--fs-12);
  font-weight: var(--fw-semi);
  color: var(--color-text-muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.table tbody tr:hover { background: var(--sabin-offwhite-2); }
.table .row-num { font-family: var(--font-mono); color: var(--color-text-muted); font-size: var(--fs-13); }

/* ---------- NAVIGATION ---------- */
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-14); font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
}
.nav-item:hover { background: var(--neutral-100); color: var(--color-text); }
.nav-item.is-active {
  background: var(--sabin-red);
  color: white;
}
.nav-item.is-active .nav-item__count { background: rgba(255,255,255,.18); color: white; }
.nav-item .icon { width: 18px; height: 18px; flex: none; }
.nav-item__count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  height: 18px; min-width: 22px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  background: var(--neutral-100);
  color: var(--color-text-muted);
}

/* ---------- BREADCRUMB ---------- */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: var(--fs-13); color: var(--color-text-muted); }
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-text); text-decoration: none; }
.breadcrumb__sep { color: var(--neutral-400); }
.breadcrumb__current { color: var(--color-text); font-weight: var(--fw-semi); }

/* ---------- TABS ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); }
.tab {
  padding: 12px 16px;
  font-size: var(--fs-14); font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--color-text); }
.tab.is-active { color: var(--sabin-red); border-bottom-color: var(--sabin-red); }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 4px;
  background: var(--neutral-100);
  border-radius: var(--r-pill);
  gap: 2px;
}
.segmented__item {
  padding: 0 14px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-13); font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.segmented__item.is-active {
  background: var(--color-bg-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ---------- ALERT / BANNER ---------- */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--neutral-100);
  border-left: 3px solid var(--neutral-400);
  font-size: var(--fs-14);
}
.alert .icon { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert__title { font-weight: var(--fw-semi); margin: 0 0 2px; }
.alert--info    { background: var(--color-info-bg);    border-left-color: var(--color-info);    color: #0e3d80; }
.alert--success { background: var(--color-success-bg); border-left-color: var(--color-success); color: #0e5238; }
.alert--warning { background: var(--color-warning-bg); border-left-color: var(--color-warning); color: #6e4806; }
.alert--danger  { background: var(--color-danger-bg);  border-left-color: var(--color-danger);  color: var(--sabin-red-800); }

/* ---------- TOAST ---------- */
.toast {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--neutral-900);
  color: white;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px; max-width: 380px;
  font-size: var(--fs-14);
}
.toast .icon { flex: none; width: 18px; height: 18px; }
.toast__title { font-weight: var(--fw-semi); }
.toast__body { color: rgba(255,255,255,.72); font-size: var(--fs-13); }

/* ---------- AVATAR ---------- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sabin-bege);
  color: var(--neutral-800);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: var(--fw-semi); font-size: var(--fs-13);
  flex: none;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.04);
}
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg { width: 48px; height: 48px; font-size: var(--fs-16); }
.avatar--xl { width: 72px; height: 72px; font-size: var(--fs-24); }
.avatar--brand { background: var(--sabin-red); color: white; }
.avatar-group { display: inline-flex; }
.avatar-group .avatar + .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--color-bg-surface); }

/* ---------- PROGRESS ---------- */
.progress { width: 100%; height: 6px; background: var(--neutral-100); border-radius: var(--r-pill); overflow: hidden; }
.progress__bar { height: 100%; background: var(--sabin-red); border-radius: inherit; transition: width var(--dur-slow) var(--ease-out); }

/* ---------- TOOLTIP (preview only) ---------- */
.tooltip {
  display: inline-flex;
  padding: 6px 10px;
  background: var(--neutral-900);
  color: white;
  border-radius: var(--r-sm);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

/* ---------- DIVIDER ---------- */
.divider { height: 1px; background: var(--color-divider); border: 0; margin: 0; }

/* ---------- KBD ---------- */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--neutral-00);
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
}

/* ---------- EMPTY STATE ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--r-lg);
  background: var(--sabin-offwhite-2);
}
.empty__icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--sabin-bege);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  color: var(--neutral-700);
}
.empty__title { font-size: var(--fs-16); font-weight: var(--fw-semi); margin: 0 0 4px; }
.empty__body  { font-size: var(--fs-14); color: var(--color-text-muted); max-width: 360px; margin: 0 auto 16px; }
