/* ============================================================
   components.css — reusable classes replacing the common
   Tailwind arbitrary-value patterns. Colors come from tokens.
   ============================================================ */

/* ── Header badges + warning banner ─────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 6px var(--sp-4);
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.badge img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.badge--company {
  background: var(--c-company-bg);
  border: 1px solid var(--c-company-border);
}
.badge--company span {
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--c-company-text);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-5);
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  border-radius: var(--r-md);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s, opacity 0.15s,
    border-color 0.15s;
}
.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}
.btn-primary {
  background: var(--c-orange);
  color: #fff;
  box-shadow: var(--sh-btn);
}
.btn-primary:hover:not(:disabled) {
  background: var(--c-orange-ink);
}
.btn-primary:disabled {
  background: var(--c-border);
  color: #fff;
  box-shadow: none;
  opacity: 1;
}
.btn-secondary {
  background: var(--c-blue);
  color: #fff;
}
.btn-secondary:hover:not(:disabled) {
  filter: brightness(0.94);
}
.btn-ghost {
  background: var(--c-surface);
  color: var(--c-text-3);
  border: 1px solid var(--c-border-input-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--c-surface-3);
}
.btn-success {
  background: var(--c-success);
  color: #fff;
}

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
}

/* ── Form fields ────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.label {
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--c-text-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.label .req {
  color: var(--c-orange);
}
.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--c-border-field);
  background: var(--c-surface);
  border-radius: var(--r-xl);
  padding: 11px 14px;
  font-size: var(--fs-14);
  color: var(--c-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--c-text-faint);
}
.input:hover:not(:focus):not(:disabled),
.textarea:hover:not(:focus):not(:disabled),
.select:hover:not(:focus):not(:disabled) {
  border-color: var(--c-border-field-strong);
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--c-indigo);
  box-shadow: var(--ring-field);
}
.input:disabled,
.textarea:disabled,
.select:disabled {
  background: var(--c-surface-3);
  color: var(--c-text-faint);
  cursor: not-allowed;
}
.input.is-error,
.textarea.is-error,
.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--c-danger);
}
.input.is-error:focus,
.textarea.is-error:focus,
.input[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  border-color: var(--c-danger-ink);
  box-shadow: var(--ring-error);
}
.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
.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='%23888' stroke-width='2' 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 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.field-error {
  font-size: var(--fs-12);
  color: var(--c-danger);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ── Status pills ───────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.pill--success {
  background: var(--c-success-bg);
  color: var(--c-success-ink);
}
.pill--danger {
  background: var(--c-danger-bg);
  color: var(--c-danger-ink);
}
.pill--warn {
  background: var(--c-warn-soft-bg);
  color: var(--c-warn-soft-ink);
}
.pill--blue {
  background: var(--c-blue-soft);
  color: var(--c-blue);
}
.pill--gray {
  background: var(--c-surface-3);
  color: var(--c-text-muted);
}

/* ── Modal (ports Modal.tsx) ────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28rem;
  max-height: 90vh;
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-modal);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 16px var(--sp-7);
  border-bottom: 1px solid var(--c-border);
}
.modal-title {
  font-size: var(--fs-15);
  font-weight: var(--fw-semibold);
  color: var(--c-text);
}
.modal-close {
  display: inline-flex;
  padding: 4px;
  color: var(--c-text-faint);
  transition: color 0.15s;
}
.modal-close:hover {
  color: var(--c-text-3);
}
.modal-body {
  flex: 1;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  flex-shrink: 0;
  padding: 16px var(--sp-7);
  border-top: 1px solid var(--c-border);
}

/* ── DataTable grid (ports DataTable.tsx) ───────────────── */
.table-grid {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  width: 100%;
}
.table-grid--fit {
  width: fit-content;
}
.table-grid__head {
  display: grid;
  background: var(--c-surface-3);
  border-bottom: 1px solid var(--c-border);
}
.table-grid__row {
  display: grid;
  border-bottom: 1px solid var(--c-border);
  transition: background-color 0.15s;
}
.table-grid__row:last-child {
  border-bottom: 0;
}
.table-grid__row:hover {
  background: var(--c-surface-hover);
}
.table-grid__cell {
  display: flex;
  align-items: center;
  padding: 12px;
  font-size: var(--fs-14);
  border-right: 1px solid var(--c-border);
  min-width: 0;
}
.table-grid__cell:last-child {
  border-right: 0;
}
.table-grid__head .table-grid__cell {
  color: var(--c-text-3);
  font-weight: var(--fw-medium);
}
.table-grid__row .table-grid__cell {
  color: var(--c-text-4);
}
.table-grid--compact .table-grid__cell {
  padding: 8px 12px;
}
.is-center {
  justify-content: center;
  text-align: center;
}
.is-right {
  justify-content: flex-end;
  text-align: right;
}

/* ── Toggle switch ──────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--c-border-input-2);
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
  border: none;
  padding: 0;
}
.toggle[aria-checked="true"] {
  background: var(--c-blue);
}
.toggle__knob {
  position: absolute;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.toggle[aria-checked="true"] .toggle__knob {
  transform: translateX(16px);
}

/* ── Section card (OrderPage) ───────────────────────────── */
.section-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.section-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 14px var(--sp-5);
  border-bottom: 1px solid var(--c-border);
}
.section-card__title {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-15);
  font-weight: var(--fw-bold);
  color: var(--c-text);
}
.section-card__body {
  padding: var(--sp-5);
}

/* ── Chip (filters) ─────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--c-text-3);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover {
  border-color: var(--c-border-strong);
}
.chip.is-active {
  border-color: var(--c-orange);
  background: var(--c-orange-soft);
  color: var(--c-orange-ink);
}

/* ── Step indicator (Register) ──────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
}
.step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  background: var(--c-border);
  color: #fff;
  flex-shrink: 0;
}
.step-dot.is-current {
  background: var(--c-orange);
}
.step-dot.is-done {
  background: var(--c-dark);
}
.step-line {
  flex: 1;
  height: 2px;
  background: var(--c-border);
}
.step-line.is-done {
  background: var(--c-dark);
}

/* ── Page title (ports PageTitle.tsx) ───────────────────── */
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-7);
}
.page-title__main {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.page-title__emoji {
  font-size: var(--fs-22);
  line-height: 1;
}
.page-title__img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
.page-title h1 {
  font-size: var(--fs-22);
  font-weight: var(--fw-bold);
  color: var(--c-text);
}

/* ── Small utilities (token-driven) ─────────────────────── */
.row {
  display: flex;
  align-items: center;
}
.stack {
  display: flex;
  flex-direction: column;
}
.muted {
  color: var(--c-text-muted);
}
.spin {
  animation: spin 0.9s linear infinite;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tint-blue {
  color: var(--c-blue);
}
.tint-green {
  color: var(--c-success);
}
.tint-orange {
  color: var(--c-orange);
}
.tint-muted {
  color: var(--c-text-muted);
}
