/* Tipografía y base */
body {
  font-family: "Roboto", sans-serif;
  margin: 0;
  padding: 0;
}

/* Bloqueo global de scroll para offcanvas/modales */
html.egx-scroll-locked,
html.egx-scroll-locked body {
  overflow: hidden !important;
  touch-action: none;
}

label {
  user-select: none;
}

.egx-navbar-search {
  flex: 1 1 42rem;
  max-width: 52rem;
  min-width: 0;
}

@media (max-width: 767.98px) {
  .egx-navbar-search {
    flex-basis: 100%;
    width: 100%;
    order: 10;
    max-width: none;
  }
}

/* Tokens EGX: forma una vez; claro por defecto; oscuro solo color */
:root {
  color-scheme: light dark;
  --egx-page-nav-height: 4rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius: var(--radius-md);
  --bs-border-radius-lg: var(--radius-lg);
  --bs-border-radius-xl: var(--radius-lg);
  --bs-border-radius-2xl: var(--radius-lg);
  --bs-border-radius-xxl: var(--radius-lg);
  --bs-border-radius-pill: var(--radius-pill);

  /* Marca EnduroGearX (claro) */
  --md-sys-color-primary: #f15a24;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-secondary: #d94e1e;
  --md-sys-color-background: #ffffff;
  --md-sys-color-on-background: #1c1b1f;
  --md-sys-color-surface: #ffffff;
  --md-sys-color-on-surface: #1c1b1f;
  --md-sys-color-surface-variant: #f4e7e3;
  --md-sys-color-outline: #c4c7c5;
  --md-sys-color-primary-container: #ffe4d6;
  --md-sys-color-on-primary-container: #2b0d00;

  --bs-focus-ring-color: color-mix(in srgb, var(--md-sys-color-primary) 35%, transparent);
  --egx-disabled-surface: color-mix(in srgb, var(--md-sys-color-surface-variant) 72%, var(--md-sys-color-surface) 28%);
  --egx-disabled-border: color-mix(in srgb, var(--md-sys-color-outline) 82%, var(--md-sys-color-surface) 18%);
  --egx-disabled-text: color-mix(in srgb, var(--md-sys-color-on-surface) 42%, var(--md-sys-color-surface) 58%);
  --egx-disabled-accent: color-mix(in srgb, var(--md-sys-color-primary) 26%, var(--egx-disabled-surface) 74%);

  --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.14);
  --elevation-2: 0 2px 4px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.14);

  --bs-primary: var(--md-sys-color-primary);
  --bs-secondary: var(--md-sys-color-secondary);
  --egx-primary-rgb: 241, 90, 36;
  --egx-secondary-rgb: 217, 78, 30;
  --bs-primary-rgb: var(--egx-primary-rgb);
  --bs-secondary-rgb: var(--egx-secondary-rgb);
  --bs-body-bg: var(--md-sys-color-background);
  --bs-body-color: var(--md-sys-color-on-background);
  --bs-link-color: var(--md-sys-color-primary);
  --bs-link-hover-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, black 15%);
  --bs-border-color: var(--md-sys-color-outline);
}

:root[data-theme="dark"] {
  --md-sys-color-primary: #ff8a50;
  --md-sys-color-on-primary: #3b1f12;
  --md-sys-color-secondary: #ff6e40;
  --md-sys-color-background: #16181d;
  --md-sys-color-on-background: #e5e7eb;
  --md-sys-color-surface: #1c2027;
  --md-sys-color-on-surface: #e5e7eb;
  --md-sys-color-surface-variant: #262b33;
  --md-sys-color-outline: #343a40;
  --md-sys-color-primary-container: #3b1f12;
  --md-sys-color-on-primary-container: #ffdbcc;
  --elevation-1: 0 1px 1px rgba(0, 0, 0, 0.45), 0 2px 2px rgba(0, 0, 0, 0.35);
  --elevation-2: 0 2px 3px rgba(0, 0, 0, 0.5), 0 6px 6px rgba(0, 0, 0, 0.4);
  --bs-link-hover-color: color-mix(in srgb, var(--md-sys-color-primary) 85%, white 15%);
  --egx-primary-rgb: 255, 138, 80;
  --egx-secondary-rgb: 255, 110, 64;
  --bs-primary-rgb: var(--egx-primary-rgb);
  --bs-secondary-rgb: var(--egx-secondary-rgb);
}

/* Componentes con tokens MD + Bootstrap */
.btn {
  --bs-btn-border-radius: var(--radius-sm);
}

.btn-primary {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-1);
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

/* Ajustes contextuales de Bootstrap para respetar el tema global */
.bg-light {
  background-color: color-mix(in srgb, var(--md-sys-color-surface) 96%, var(--md-sys-color-on-surface) 4%) !important;
}

.bg-body-tertiary {
  background-color: color-mix(in srgb, var(--md-sys-color-surface) 94%, var(--md-sys-color-on-surface) 6%) !important;
}

.text-body-secondary {
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 60%, transparent) !important;
}

.text-primary {
  color: var(--md-sys-color-primary) !important;
}

.text-secondary {
  color: var(--md-sys-color-secondary) !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--md-sys-color-secondary);
  border-color: var(--md-sys-color-secondary);
  box-shadow: var(--elevation-2);
}

.btn-outline-primary {
  color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  border-radius: var(--radius-sm);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  color: var(--md-sys-color-on-primary);
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--elevation-2);
}

.btn-secondary {
  background-color: var(--md-sys-color-primary-container);
  border-color: color-mix(in srgb, var(--md-sys-color-primary-container) 85%, var(--md-sys-color-outline) 15%);
  color: var(--md-sys-color-on-primary-container);
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-1);
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.btn-secondary:hover,
.btn-secondary:focus {
  background-color: color-mix(in srgb, var(--md-sys-color-primary-container) 75%, var(--md-sys-color-primary) 25%);
  border-color: color-mix(in srgb, var(--md-sys-color-primary-container) 70%, var(--md-sys-color-primary) 30%);
  box-shadow: var(--elevation-2);
}

.btn-warning {
  background-color: color-mix(in srgb, var(--md-sys-color-secondary) 90%, var(--md-sys-color-primary) 10%);
  border-color: color-mix(in srgb, var(--md-sys-color-secondary) 85%, var(--md-sys-color-primary) 15%);
  color: var(--md-sys-color-on-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-1);
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.btn-warning:hover,
.btn-warning:focus {
  background-color: color-mix(in srgb, var(--md-sys-color-secondary) 75%, var(--md-sys-color-primary) 25%);
  border-color: color-mix(in srgb, var(--md-sys-color-secondary) 70%, var(--md-sys-color-primary) 30%);
  box-shadow: var(--elevation-2);
}

.btn-outline-warning {
  color: color-mix(in srgb, var(--md-sys-color-secondary) 70%, var(--md-sys-color-primary) 30%);
  border-color: color-mix(in srgb, var(--md-sys-color-secondary) 70%, var(--md-sys-color-primary) 30%);
  border-radius: var(--radius-sm);
}

.btn-outline-warning:hover,
.btn-outline-warning:focus {
  color: var(--md-sys-color-on-primary);
  background-color: color-mix(in srgb, var(--md-sys-color-secondary) 85%, var(--md-sys-color-primary) 15%);
  border-color: color-mix(in srgb, var(--md-sys-color-secondary) 85%, var(--md-sys-color-primary) 15%);
  box-shadow: var(--elevation-2);
}

.btn:disabled,
.btn.disabled,
.btn[aria-disabled="true"] {
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-primary:disabled,
.btn-primary.disabled,
.btn-primary[aria-disabled="true"],
.btn-secondary:disabled,
.btn-secondary.disabled,
.btn-secondary[aria-disabled="true"],
.btn-warning:disabled,
.btn-warning.disabled,
.btn-warning[aria-disabled="true"],
.btn-success:disabled,
.btn-success.disabled,
.btn-success[aria-disabled="true"],
.btn-danger:disabled,
.btn-danger.disabled,
.btn-danger[aria-disabled="true"],
.btn-dark:disabled,
.btn-dark.disabled,
.btn-dark[aria-disabled="true"] {
  background-color: var(--egx-disabled-accent);
  border-color: color-mix(in srgb, var(--egx-disabled-accent) 72%, var(--md-sys-color-outline) 28%);
  color: var(--egx-disabled-text);
}

.btn-outline-primary:disabled,
.btn-outline-primary.disabled,
.btn-outline-primary[aria-disabled="true"],
.btn-outline-secondary:disabled,
.btn-outline-secondary.disabled,
.btn-outline-secondary[aria-disabled="true"],
.btn-outline-warning:disabled,
.btn-outline-warning.disabled,
.btn-outline-warning[aria-disabled="true"],
.btn-outline-success:disabled,
.btn-outline-success.disabled,
.btn-outline-success[aria-disabled="true"],
.btn-outline-danger:disabled,
.btn-outline-danger.disabled,
.btn-outline-danger[aria-disabled="true"],
.btn-outline-dark:disabled,
.btn-outline-dark.disabled,
.btn-outline-dark[aria-disabled="true"] {
  background-color: var(--egx-disabled-surface);
  border-color: var(--egx-disabled-border);
  color: var(--egx-disabled-text);
}

.alert {
  border-radius: var(--radius-md);
  border: 1px solid var(--md-sys-color-outline);
  box-shadow: var(--elevation-1);
}

.alert-success {
  --egx-success: #158000;
  background-color: color-mix(in srgb, var(--md-sys-color-surface) 88%, var(--egx-success) 12%);
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 85%, var(--egx-success) 15%);
  border-color: color-mix(in srgb, var(--egx-success) 50%, var(--md-sys-color-outline) 50%);
}

.alert-info {
  --egx-info: #0ea5e9;
  background-color: color-mix(in srgb, var(--md-sys-color-surface) 88%, var(--egx-info) 12%);
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 85%, var(--egx-info) 15%);
  border-color: color-mix(in srgb, var(--egx-info) 50%, var(--md-sys-color-outline) 50%);
}

.card,
.dropdown-menu,
.offcanvas,
.modal-content {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
  box-shadow: var(--elevation-1);
}

.card,
.dropdown-menu {
  border-radius: var(--radius-md);
}

.offcanvas,
.modal-content {
  border-radius: var(--radius-lg);
}

.egx-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1085;
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 32%, transparent);
  backdrop-filter: blur(3px);
}

.egx-dialog-panel {
  max-width: min(92vw, 380px);
}

.navbar,
.toast {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--elevation-1);
}

.nav-pills .nav-link.active,
.nav-link.active {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 88%, black 12%);
  color: var(--md-sys-color-on-primary);
  border-radius: var(--radius-sm);
}

.badge.bg-primary {
  background-color: var(--md-sys-color-primary) !important;
  color: var(--md-sys-color-on-primary) !important;
}

.form-control,
.form-select,
.form-check-input {
  background-color: color-mix(in srgb, var(--md-sys-color-surface) 96%, var(--md-sys-color-on-surface) 4%);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.form-control,
.form-select,
.form-check-input[type="checkbox"] {
  border-radius: var(--radius-sm);
}

.form-check-input[type="radio"] {
  border-radius: 50%;
}

.form-control::placeholder {
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 55%, transparent);
  opacity: 1;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow:
    0 0 0 0.025rem var(--md-sys-color-primary),
    0 0.2rem 0.45rem rgba(0, 0, 0, 0.12);
}

.form-control:disabled,
.form-select:disabled {
  background-color: var(--egx-disabled-surface);
  border-color: var(--egx-disabled-border);
  color: var(--egx-disabled-text);
  -webkit-text-fill-color: var(--egx-disabled-text);
  opacity: 1;
  cursor: not-allowed;
}

.form-control:disabled::placeholder {
  color: color-mix(in srgb, var(--egx-disabled-text) 75%, transparent);
}

.form-check-input:focus {
  box-shadow:
    0 0 0 0.025rem var(--md-sys-color-primary),
    0 0.2rem 0.45rem rgba(0, 0, 0, 0.12);
  border-color: var(--md-sys-color-primary);
}

.form-check-input:checked {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

.form-check-input:disabled {
  background-color: var(--egx-disabled-surface);
  border-color: var(--egx-disabled-border);
  opacity: 1;
  cursor: not-allowed;
}

.form-check-input:checked:disabled {
  background-color: var(--egx-disabled-accent);
  border-color: color-mix(in srgb, var(--egx-disabled-accent) 70%, var(--egx-disabled-border) 30%);
}

.form-check-input:disabled + .form-check-label,
.form-check-input:disabled ~ .form-check-label {
  color: var(--egx-disabled-text);
  cursor: not-allowed;
}

.page-item.disabled .page-link,
.page-link.disabled {
  background-color: var(--egx-disabled-surface);
  border-color: var(--egx-disabled-border);
  color: var(--egx-disabled-text);
  opacity: 1;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

hr {
  color: var(--md-sys-color-outline);
}

::selection {
  background: color-mix(in srgb, var(--md-sys-color-primary) 25%, transparent);
  color: inherit;
}

/* ===== Loader global (overlay) ===== */
#egx-loader.d-none {
  display: none !important;
}

#egx-loader {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
}

#egx-loader .egx-loader__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 20%, transparent);
  backdrop-filter: blur(6px) saturate(1.05);
}

#egx-loader .egx-loader__panel {
  position: relative;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--elevation-2);
  border: 1px solid var(--md-sys-color-outline);
  min-width: 240px;
}

#egx-loader .egx-loader__title {
  font-weight: 600;
  margin: 0;
}

#egx-loader .egx-loader__desc {
  margin: 0.25rem 0 0;
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 70%, transparent);
  font-size: 0.95rem;
}
