/* =========================================================================
   CommandX · Bootstrap component theming
   Uses Bootstrap's own component CSS variables (--bs-btn-*, --bs-modal-*, ...)
   so markup keeps standard Bootstrap classes.
   ========================================================================= */

/* ---------- Buttons ---------- */
.btn {
  --bs-btn-font-family: var(--cx-font-sans);
  --bs-btn-font-size: var(--cx-fs-base);
  --bs-btn-font-weight: 600;
  --bs-btn-padding-x: 1rem;
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-border-radius: var(--cx-radius);
  --bs-btn-focus-box-shadow: var(--cx-focus-ring);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1.4;
  transition: background-color 0.18s var(--cx-ease), border-color 0.18s var(--cx-ease), color 0.18s var(--cx-ease), box-shadow 0.18s var(--cx-ease);
}

/* Element-qualified so generic resets like `[type='button'] { background: transparent }`
   (e.g. Tailwind preflight while it is still loaded) cannot blank out buttons. */
button.btn,
a.btn,
input.btn {
  background-color: var(--bs-btn-bg);
}

button.btn-close {
  background: transparent var(--bs-btn-close-bg) center / 1em auto no-repeat;
}

.btn-sm {
  --bs-btn-font-size: var(--cx-fs-sm);
  --bs-btn-padding-x: 0.875rem;
  --bs-btn-padding-y: 0.375rem;
}

.btn-lg {
  --bs-btn-font-size: var(--cx-fs-md);
  --bs-btn-padding-x: 1.5rem;
  --bs-btn-padding-y: 0.75rem;
}

.btn-primary {
  --bs-btn-color: #ffffff;
  --bs-btn-bg: var(--cx-navy);
  --bs-btn-border-color: var(--cx-navy);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--cx-navy-600);
  --bs-btn-hover-border-color: var(--cx-navy-600);
  --bs-btn-active-color: #ffffff;
  --bs-btn-active-bg: var(--cx-navy-dark);
  --bs-btn-active-border-color: var(--cx-navy-dark);
  --bs-btn-disabled-bg: var(--cx-navy);
  --bs-btn-disabled-border-color: var(--cx-navy);
  box-shadow: var(--cx-shadow-navy);
}

.btn-danger {
  --bs-btn-color: #ffffff;
  --bs-btn-bg: var(--cx-crimson);
  --bs-btn-border-color: var(--cx-crimson);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--cx-crimson-dark);
  --bs-btn-hover-border-color: var(--cx-crimson-dark);
  --bs-btn-active-bg: var(--cx-crimson-dark);
  --bs-btn-active-border-color: var(--cx-crimson-dark);
}

/* Secondary = white outline button (design: "Secondary / Outline") */
.btn-secondary,
.btn-outline-secondary {
  --bs-btn-color: var(--cx-text-strong);
  --bs-btn-bg: #ffffff;
  --bs-btn-border-color: var(--cx-border-strong);
  --bs-btn-hover-color: var(--cx-navy);
  --bs-btn-hover-bg: var(--cx-slate-100);
  --bs-btn-hover-border-color: var(--cx-navy);
  --bs-btn-active-color: var(--cx-navy);
  --bs-btn-active-bg: var(--cx-slate-100);
  --bs-btn-active-border-color: var(--cx-navy);
  box-shadow: var(--cx-shadow-xs);
}

.btn-outline-primary {
  --bs-btn-color: var(--cx-navy);
  --bs-btn-border-color: var(--cx-navy);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--cx-navy);
  --bs-btn-hover-border-color: var(--cx-navy);
  --bs-btn-active-bg: var(--cx-navy-dark);
  --bs-btn-active-border-color: var(--cx-navy-dark);
}

/* Light = neutral filled button (e.g. filter Reset) */
.btn-light {
  --bs-btn-color: var(--cx-slate-700);
  --bs-btn-bg: var(--cx-slate-100);
  --bs-btn-border-color: var(--cx-slate-200);
  --bs-btn-hover-color: var(--cx-slate-800);
  --bs-btn-hover-bg: var(--cx-slate-200);
  --bs-btn-hover-border-color: var(--cx-slate-200);
  --bs-btn-active-bg: var(--cx-slate-200);
  --bs-btn-active-border-color: var(--cx-slate-300);
  --bs-btn-font-weight: 500;
}

/* Plain icon button (menu toggles, etc.) */
.btn-icon {
  --bs-btn-padding-x: 0.5rem;
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-color: var(--cx-slate-600);
  --bs-btn-hover-bg: var(--cx-slate-100);
  --bs-btn-hover-color: var(--cx-text-strong);
  --bs-btn-active-bg: var(--cx-slate-100);
  --bs-btn-border-color: transparent;
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-border-color: transparent;
  line-height: 1;
}

/* ---------- Forms ---------- */
/* Element-qualified (input./select./textarea.) to win over generic form resets. */
input.form-control,
textarea.form-control,
select.form-select {
  font-size: var(--cx-fs-base);
  line-height: 1.5;
  color: var(--cx-text-strong);
  background-color: #ffffff;
  border: 1px solid var(--cx-border-strong);
  border-radius: var(--cx-radius-sm);
  min-height: 2.375rem;
  padding: 0.5rem 0.85rem;
}

select.form-select {
  padding-right: 2.25rem;
  background-image: var(--bs-form-select-bg-img);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
}

input.form-control:focus,
textarea.form-control:focus,
select.form-select:focus {
  border-color: var(--cx-navy);
  outline: 0;
  box-shadow: var(--cx-focus-ring);
}

.form-control::placeholder {
  color: var(--cx-text-subtle);
}

.form-control[readonly] {
  background-color: var(--cx-slate-50);
  cursor: not-allowed;
}

.form-label {
  font-size: var(--cx-fs-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--cx-slate-600);
  margin-bottom: 0.3125rem;
}

/* ---------- Cards ---------- */
.card {
  --bs-card-bg: var(--cx-surface);
  --bs-card-color: var(--cx-text-strong);
  --bs-card-border-color: var(--cx-slate-200);
  --bs-card-border-radius: var(--cx-radius-lg);
  --bs-card-inner-border-radius: calc(var(--cx-radius-lg) - 1px);
  --bs-card-cap-bg: transparent;
  --bs-card-cap-padding-y: 0.875rem;
  --bs-card-cap-padding-x: 1.25rem;
  --bs-card-spacer-y: 1.25rem;
  --bs-card-spacer-x: 1.25rem;
  box-shadow: var(--cx-shadow-sm);
}

.form-check-input {
  border-color: var(--cx-border-strong);
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--cx-navy);
  border-color: var(--cx-navy);
}

.form-check-input:focus {
  border-color: var(--cx-navy);
  box-shadow: var(--cx-focus-ring);
}

.form-text,
.invalid-feedback {
  font-size: var(--cx-fs-sm);
}

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--cx-text-strong);
  --bs-table-border-color: var(--cx-slate-100);
  --bs-table-hover-bg: var(--cx-slate-50);
  --bs-table-striped-bg: var(--cx-slate-50);
  font-size: var(--cx-fs-base);
  margin-bottom: 0;
}

.table > thead > tr > th {
  background-color: var(--cx-surface-muted);
  color: var(--cx-text-muted);
  font-size: var(--cx-fs-xs);
  font-weight: 700;
  letter-spacing: var(--cx-tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.6875rem 1rem;
  border-bottom: 2px solid var(--cx-slate-200);
}

.table > tbody > tr > td {
  padding: 0.6875rem 1rem;
  vertical-align: middle;
}

.table td.text-end,
.table th.text-end {
  font-variant-numeric: tabular-nums;
}

/* ---------- Badges ---------- */
.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---------- Alerts ---------- */
.alert {
  --bs-alert-padding-y: 0.625rem;
  --bs-alert-padding-x: 0.875rem;
  --bs-alert-border-radius: var(--cx-radius);
  font-size: var(--cx-fs-base);
}

/* ---------- Modals ---------- */
.modal {
  --bs-modal-bg: var(--cx-surface);
  --bs-modal-color: var(--cx-text-strong);
  --bs-modal-border-color: var(--cx-slate-200);
  --bs-modal-border-radius: var(--cx-radius-lg);
  --bs-modal-box-shadow: var(--cx-shadow-lg);
  --bs-modal-header-padding: 1rem 1.375rem;
  --bs-modal-header-border-color: var(--cx-slate-100);
  --bs-modal-padding: 1.375rem;
  --bs-modal-footer-border-color: var(--cx-slate-100);
  --bs-modal-title-line-height: 1.3;
}

.modal-content {
  box-shadow: var(--cx-shadow-lg);
}

.modal-title {
  font-size: var(--cx-fs-lg);
  font-weight: 700;
  color: var(--cx-navy);
}

/* ---------- Toasts ---------- */
.toast {
  --bs-toast-bg: var(--cx-surface);
  --bs-toast-color: var(--cx-text-strong);
  --bs-toast-border-radius: var(--cx-radius-lg);
  --bs-toast-box-shadow: var(--cx-shadow-lg);
  --bs-toast-font-size: var(--cx-fs-base);
}

/* ---------- Tooltips ---------- */
.tooltip {
  --bs-tooltip-bg: var(--cx-navy-dark);
  --bs-tooltip-font-size: var(--cx-fs-sm);
  --bs-tooltip-border-radius: var(--cx-radius-sm);
}

/* ---------- Dropdowns ---------- */
.dropdown-menu {
  --bs-dropdown-font-size: var(--cx-fs-base);
  --bs-dropdown-border-color: var(--cx-slate-200);
  --bs-dropdown-border-radius: var(--cx-radius-lg);
  --bs-dropdown-box-shadow: var(--cx-shadow-md);
  --bs-dropdown-link-color: var(--cx-text);
  --bs-dropdown-link-hover-color: var(--cx-navy);
  --bs-dropdown-link-hover-bg: var(--cx-slate-50);
  --bs-dropdown-link-active-bg: var(--cx-navy);
}
