/**
 * Shim minimo para reutilizar componentes legacy (jQuery/Bootstrap 4: modales,
 * grid, formularios, botones) dentro de las vistas v2, que no cargan
 * public/css/app.css (Bootstrap). Solo cubre las clases usadas por los
 * componentes legacy que todavia se reutilizan en v2 (ej. algun modal de
 * direccion en main_address/onboarding). ModalPickupNational, ModalHelpSize,
 * ModalEnvioNacionalStatus y ButtonEnvioNacionalExcel ya tienen su version V2
 * nativa (.ep-modal-*) y no dependen de este shim.
 * No se define bajo un selector .v2-* porque Bootstrap (via jQuery) inserta
 * el backdrop directamente en <body>, fuera del árbol de componentes v2.
 */

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(10, 10, 10, .55);
}

.modal-dialog {
  position: relative;
  width: auto;
  margin: 24px auto;
  max-width: 500px;
  pointer-events: none;
}

.modal-dialog.modal-lg { max-width: 720px; }
.modal-dialog.modal-xs { max-width: 360px; }
.modal-dialog.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 48px);
}

@media (max-width: 576px) {
  .modal-dialog { margin: 12px; }
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 48px rgba(15, 23, 42, .18);
  outline: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--tx-strong);
  letter-spacing: -.02em;
}

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.modal-content .close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--tx-muted);
  cursor: pointer;
  padding: 0;
}

.modal-content img { max-width: 100%; height: auto; }

/* Grid (subconjunto usado por los modales legacy) */
.modal-content .row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.modal-content [class*="col-"] { padding: 0 8px; box-sizing: border-box; width: 100%; }
.modal-content .col-sm-12 { width: 100%; }
@media (min-width: 768px) {
  .modal-content .col-md-12 { width: 100%; }
  .modal-content .col-md-10 { width: 83.333333%; }
  .modal-content .col-md-8 { width: 66.666667%; }
  .modal-content .col-md-6 { width: 50%; }
  .modal-content .col-md-4 { width: 33.333333%; }
  .modal-content .col-md-2 { width: 16.666667%; }
  .modal-content .offset-md-3 { margin-left: 25%; }
}

/* Formularios */
.modal-content .form-row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.modal-content .form-row > [class*="col-"] { padding: 0 8px; }
.modal-content .form-group { margin-bottom: 14px; }
.modal-content label { display: block; font-size: 12.5px; font-weight: 600; color: var(--tx-strong); margin-bottom: 6px; }

.modal-content .form-control,
.modal-content .form-control-plaintext,
.modal-content select.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--tx-strong);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.modal-content .form-control-plaintext {
  border-color: transparent;
  background: var(--bg-hover);
}

.modal-content .input-group { display: flex; align-items: stretch; width: 100%; }
.modal-content .input-group .form-control,
.modal-content .input-group .form-control-plaintext { border-radius: var(--r-md) 0 0 var(--r-md); }
.modal-content .input-group-append,
.modal-content .input-group-prepend { display: flex; }
.modal-content .input-group-prepend .input-group-text { border-radius: var(--r-md) 0 0 var(--r-md); border-right: none; }
.modal-content .input-group-prepend + .form-control { border-radius: 0 var(--r-md) var(--r-md) 0; }
.modal-content .input-group-text {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--bg-hover);
  color: var(--tx-muted);
}

.modal-content .form-text { margin-top: 6px; font-size: 12px; }
.modal-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Botones (variantes bootstrap de un solo guion, .btn base ya existe en v2/app.css) */
.btn-primary   { background: var(--tx-strong); color: #fff; }
.btn-primary:hover { background: #2a2a2a; color: #fff; }
.btn-secondary { background: var(--bg-hover); color: var(--tx-base); }
.btn-secondary:hover { background: var(--border); }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover { background: #128a3e; color: #fff; }
.btn-outline-primary { background: transparent; color: var(--tx-strong); border: 1px solid var(--border); }
.btn-outline-primary:hover { background: var(--bg-hover); }
.btn-outline-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-outline-danger:hover { background: var(--red-bg); }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Utilidades usadas dentro de los modales legacy */
.modal-content .text-center { text-align: center; }
.modal-content .text-right { text-align: right; }
.modal-content .text-muted { color: var(--tx-muted); }
.modal-content .text-danger { color: var(--red); }
.modal-content .font-weight-bold { font-weight: 700; }
.modal-content .mb-3 { margin-bottom: 12px; }
.modal-content .mr-2 { margin-right: 8px; }
.modal-content .py-4 { padding-top: 20px; padding-bottom: 20px; }
.modal-content .py-1 { padding-top: 4px; padding-bottom: 4px; }
.modal-content .px-3 { padding-left: 12px; padding-right: 12px; }
.modal-content .d-flex { display: flex; }
.modal-content .justify-content-end { justify-content: flex-end; }
.modal-content .justify-content-center { justify-content: center; }
.modal-content .align-items-center { align-items: center; }

/* Barra de progreso (excel export) */
.progress {
  display: flex;
  height: 8px;
  overflow: hidden;
  background: var(--bg-hover);
  border-radius: var(--r-pill);
  margin-bottom: 8px;
}
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  background: var(--orange);
  transition: width .3s ease;
  white-space: nowrap;
}

/* Spinners bootstrap usados por SpinnerButton/SpinnerLoader */
.spinner-border {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  vertical-align: -.125em;
  border: .2em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: v2-spinner-rotate .75s linear infinite;
}

.spinner-border-sm { width: 1rem; height: 1rem; border-width: .15em; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes v2-spinner-rotate {
  to { transform: rotate(360deg); }
}
