:root {
    --primary-color: #8B1C16; /* Rojo oscuro */
    --primary-color-hover: #8B1C16;
    --bg-light: #f8f9fa;
    --text-dark: #212529;
    --table-header-bg: #f1f1f1;
    --table-border: #dee2e6;
}

/* General */
body {
    background-color: var(--bg-light);
    font-family: 'Montserrat', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-dark);
}

/* Navbar */
.navbar {
    background-color: var(--primary-color);
}
.navbar .navbar-brand,
.navbar .nav-link {
    color: #fff !important;
}
.navbar .nav-link:hover {
    background-color: var(--primary-color-hover);
    border-radius: 5px;
}

/* Botones */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.btn-primary:hover {
    background-color: var(--primary-color-hover);
    border-color: var(--primary-color-hover);
}

/* Formularios */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 .25rem rgba(139, 28, 22, 0.25);
}

/* Tablas */
.table {
    border: 1px solid var(--table-border);
    background-color: #fff;
}
.table thead {
    background-color: var(--table-header-bg);
}
.table th {
    font-weight: 600;
}
.table td {
    vertical-align: middle;
}

/* Alertas */
.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}
.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: #fff;
    padding: 1rem 0;
    text-align: center;
}
/* =========================
   Ajustes para botones "X" y Select2 en filas de tabla
   Pegar al final del CSS principal
   ========================= */

/* Botón eliminar (X) pequeño, centrado y sin provocar reflow */
#tablaItems .btn-eliminar-fila {
  display: inline-flex !important;   /* inline para no forzar línea nueva */
  flex: 0 0 34px !important;         /* ancho fijado */
  width: 34px !important;
  height: 34px !important;           /* altura fijada acorde a la fila */
  padding: 0 !important;             /* evita padding que aumente altura */
  margin: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  vertical-align: middle !important;
  border-radius: 50% !important;     /* opcional: circular */
  box-sizing: border-box !important;
  white-space: nowrap !important;
}

/* Icono dentro del botón ligeramente reducido */
#tablaItems .btn-eliminar-fila i {
  font-size: 1rem;
  line-height: 1;
  display: inline-block;
}

/* Forzar que la celda de acción no haga wrap y mantenga su tamaño */
#tablaItems td:last-child,
#tablaItems th:last-child {
  white-space: nowrap;
  width: 70px; /* ajusta según gustes */
}

/* Reducir padding general de filas pequeñas para evitar crecimiento vertical */
#tablaItems.table-sm td, #tablaItems.table-sm th {
  padding: .35rem .45rem;
}

/* ========== Select2 dentro de tabla (evitar que la X dentro de Select2 empuje la fila) ========== */
/* Asegurar selección compacta */
.select2-container--bootstrap-5 .select2-selection {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  height: 34px;           /* concuerda con el botón eliminar */
  padding: .2rem .45rem;
  box-sizing: border-box;
}

/* Selección: texto no debe envolver */
.select2-container--bootstrap-5 .select2-selection__rendered {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Botón de "clear" (la X interna de Select2) tamaño controlado y posición */
.select2-container--bootstrap-5 .select2-selection__clear {
  width: 22px;
  height: 22px;
  padding: 0;
  margin-right: .25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 50%;
}

/* Icono clear más pequeño */
.select2-container--bootstrap-5 .select2-selection__clear::after {
  font-size: .9rem;
  vertical-align: middle;
}

/* Forzar que el contenedor Select2 no aumente la altura de la fila */
/* (útil si por defecto tiene padding grande) */
.select2-container--bootstrap-5 .select2-selection--single {
  min-height: 34px;
  height: 34px;
  padding-top: 0;
  padding-bottom: 0;
}

/* Cuando el dropdown se abre, elevar z-index para que quede encima del modal/tabla */
.select2-container--open {
  z-index: 210000 !important;
}

/* =========================
   Estética del modal "detalle" (mejor presentación)
   ========================= */
#modalVer .modal-body {
  background: #fff;
  border-radius: 6px;
  padding: 1rem;
}

#modalVer .modal-body dl dt {
  font-weight: 600;
  color: #333;
}
#modalVer .modal-body dl dd {
  margin-left: 0;
  margin-bottom: .5rem;
  color: #444;
}

/* Lista de items más legible */
#modalVer .modal-body ul {
  list-style: none;
  padding-left: 0;
}
#modalVer .modal-body ul li {
  padding: .35rem .5rem;
  border-bottom: 1px dashed #eee;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
#modalVer .modal-body ul li:last-child {
  border-bottom: none;
}

/* pequeño ajuste responsive (filas altas en pantallas pequeñas) */
@media (max-width: 640px) {
  #tablaItems td, #tablaItems th { font-size: 0.9rem; }
  #tablaItems td:last-child { width: auto; }
  #tablaItems .btn-eliminar-fila { width: 30px; height: 30px; }
  .select2-container--bootstrap-5 .select2-selection--single { height: 30px; }
}
