/* ===== new-rutas.css ===== */

/* Contenedor principal del formulario */
.formulario-ruta {
    background: white !important;
    border-radius: 10px !important;
    padding: 1.7rem !important;
    box-shadow: 0 4px 17px rgba(0,0,0,.08) !important;
    margin-top: 1.3rem !important;
    margin-bottom: 1.3rem !important;
    border: 1px solid #f0f0f0 !important;
    display: block !important;
}

/* Sistema de grilla responsivo */
.formulario-ruta .form-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
    gap: 1.3rem !important;
    margin-bottom: 1.3rem !important;
}

/* Grupos de formulario */
.formulario-ruta .form-grupo {
    display: flex !important;
    flex-direction: column !important;
}

.formulario-ruta .form-grupo label {
    font-weight: 600 !important;
    margin-bottom: 0.43rem !important;
    color: #1a202c !important;
    font-size: 0.77rem !important;
}

.formulario-ruta .form-grupo input,
.formulario-ruta .form-grupo select,
.formulario-ruta .form-grupo textarea {
    padding: 0.64rem !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 7px !important;
    font-family: 'Nunito', sans-serif !important;
    font-size: 0.77rem !important;
    transition: all 0.3s ease !important;
    background: white !important;
    box-shadow: 0 2px 5px rgba(0,0,0,.05) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.formulario-ruta .form-grupo input:focus,
.formulario-ruta .form-grupo select:focus,
.formulario-ruta .form-grupo textarea:focus {
    outline: none !important;
    border-color: #7ba5ff !important;
    box-shadow: 0 0 0 3px rgba(123, 165, 255, 0.2) !important;
    transform: translateY(-1px) !important;
}

.formulario-ruta .form-grupo textarea {
    min-height: 85px !important;
    resize: vertical !important;
    line-height: 1.5 !important;
}

/* Acciones del formulario */
.acciones-formulario {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 0.85rem !important;
    margin-top: 1.3rem !important;
    padding-top: 1.3rem !important;
    border-top: 1px solid #eee !important;
}

/* Mensajes de estado */
.mensaje-exito {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
    color: #155724 !important;
    padding: 0.85rem !important;
    border-radius: 7px !important;
    margin-bottom: 1.3rem !important;
    border: 1px solid #28a745 !important;
    display: none !important;
}

.mensaje-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%) !important;
    color: #721c24 !important;
    padding: 0.85rem !important;
    border-radius: 7px !important;
    margin-bottom: 1.3rem !important;
    border: 1px solid #dc3545 !important;
    display: none !important;
}

/* Iconos en mensajes */
.mensaje-exito i,
.mensaje-error i {
    margin-right: 0.43rem !important;
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.rutas-container {
  width: 100%;
  max-width: 100%;
  margin: 1.36rem auto;
  padding: 0 0.68rem;
  box-sizing: border-box;
}

/* ===== PANEL DE ACCIONES PRINCIPALES ===== */
.acciones {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.36rem;
  padding: 1.02rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 17px rgba(0,0,0,0.08);
  border: 1px solid #f0f0f0;
  transition: all 0.3s ease;
}

.acciones h2 {
  color: #1a202c;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  transition: font-size 0.3s ease;
}

.acciones > div {
  display: flex;
  gap: 0.68rem;
  transition: gap 0.3s ease;
}

/* ===== FILTRO ÚNICO ===== */
.filtros-container {
  background: #fff;
  padding: 1.02rem;
  border-radius: 10px;
  box-shadow: 0 4px 17px rgba(0,0,0,.08);
  margin-bottom: 1.02rem;
  border: 1px solid #f0f0f0;
}

.filtros-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.02rem;
  border-bottom: 1px solid #e8e8e8;
  padding-bottom: 0.6rem;
}

.filtros-header h3 {
  color: #1a202c;
  font-size: 0.94rem;
  font-weight: 600;
  margin: 0;
}

/* Estilos para el filtro único */
.filtro-unico-simple {
  margin-top: 0.85rem;
}

.search-container {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.68rem 0.85rem 0.68rem 0.68rem;
  border: 2px solid #e0e0e0;
  border-radius: 8.5px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.77rem;
  transition: all 0.3s ease;
  background: white;
  box-sizing: border-box;
  max-width: 238px;
  min-height: 41px;
  box-shadow: 0 2px 7px rgba(0,0,0,0.05);
}

.search-input:focus {
  outline: none;
  border-color: #7ba5ff;
  box-shadow: 0 0 0 3px rgba(123, 165, 255, 0.2);
  transform: translateY(-1px);
}

.search-input::placeholder {
  color: #9ca3af;
  font-style: italic;
}

/* ===== SISTEMA DE TABLA ===== */
.tabla-contenedor {
  background: #fff;
  padding: 1.02rem;
  border-radius: 10px;
  box-shadow: 0 4px 17px rgba(0,0,0,.08);
  overflow-x: auto;
  margin-bottom: 1.02rem;
  width: 100%;
  border: 1px solid #f0f0f0;
  -webkit-overflow-scrolling: touch;
}

.tabla,
.tabla-despachos {
  width: 100%;
  border-collapse: collapse;
  border-radius: 7px;
  overflow: hidden;
}

/* Cabeceras de tabla */
.tabla th,
.tabla-despachos th {
  background:#7ba5ff;
  color: #fff;
  padding: 0.6rem;
  text-align: left;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.34px;
  font-size: 0.64rem;
  border-bottom: 2px solid #5f76dc;
}

/* Celdas de tabla */
.tabla td,
.tabla-despachos td {
  padding: 0.6rem;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.68rem;
  text-align: left;
  color: #374151;
  vertical-align: middle;
  transition: background-color 0.2s;
}

.tabla tr:last-child td {
  border-bottom: none;
}

.tabla tr:hover,
.tabla-despachos tr:hover {
  background: #f8fafc;
}

/* Mejoras para la columna de acciones (contenedor, no botones) */
.tabla td:last-child,
.tabla-despachos td:last-child {
  padding: 0.43rem !important;
  width: auto !important;
  min-width: 102px !important;
  max-width: 128px !important;
  text-align: LEFT;
  vertical-align: middle;
}

.acciones-tabla {
  display: flex;
  gap: 0.34rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  min-width: 85px;
  max-width: 119px;
  margin: 0 auto;
}

/* ===== INDICADORES DE ESTADO ===== */
.estado {
  padding: 0.3rem 0.6rem;
  border-radius: 17px;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  display: inline-block;
  text-align: center;
  min-width: 68px;
  border: 1.5px solid;
  white-space: nowrap;
  letter-spacing: 0.26px;
  box-shadow: 0 2px 3.4px rgba(0,0,0,0.1);
}

.estado-devolucion {
  background: linear-gradient(135deg, #ffcfcf 0%, #ffabb3 100%);
  color: #721c24;
  border-color: #dc3545;
}

.estado-pendiente,
.estado-reprogramado {
  background: linear-gradient(135deg, #fff3cd 0%, #ffe695 100%);
  color: #856404;
  border-color: #ffd351;
}

.estado-entregado-parcial,
.estado-en-proceso {
  background: linear-gradient(135deg, #d1ecf1 0%, #abdae2 100%);
  color: #0c5460;
  border-color: #6edff6;
}

.estado-recogido,
.estado-completado {
  background: linear-gradient(135deg, #d4edda 0%, #96e8a9 100%);
  color: #155724;
  border-color: #28a745;
}

/* Clase para indicador de solo lectura */
.indicador-solo-lectura {
  color: #6c757d !important;
  font-style: italic;
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
}

/* ===== ESTILOS PARA CAMPOS DE SOLO LECTURA ===== */
input[readonly],
select[disabled],
input.campo-bloqueado {
  background: #f8f9fa !important;
  border-color: #e9ecef !important;
  color: #6c757d !important;
  cursor: not-allowed !important;
  opacity: 0.8 !important;
}

input[readonly]:focus,
select[disabled]:focus {
  border-color: #e9ecef !important;
  box-shadow: none !important;
  transform: none !important;
}

/* ===== ESTILOS PARA FILAS EN EDICIÓN ===== */
.fila-editando {
  background: linear-gradient(135deg, #f0f9ff 0%, #e6f7ff 100%) !important;
  border-left: 3px solid #7ba5ff;
}

.fila-editando td {
  padding: 0.68rem !important;
}

/* Inputs dentro de la tabla en modo edición */
.input-edicion {
  width: 100%;
  padding: 0.43rem 0.6rem;
  border: 2px solid #7ba5ff;
  border-radius: 7px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.68rem;
  background: white;
  box-sizing: border-box;
  min-height: 31px;
  box-shadow: 0 2px 5px rgba(123, 165, 255, 0.1);
}

.input-edicion:focus {
  outline: none;
  border-color: #5f76dc;
  box-shadow: 0 0 0 3px rgba(123, 165, 255, 0.2);
}

/* Select dentro de la tabla en modo edición */
.select-edicion {
  width: 100%;
  padding: 0.43rem 0.6rem;
  border: 2px solid #7ba5ff;
  border-radius: 7px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.68rem;
  background: white;
  box-sizing: border-box;
  min-height: 31px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(123, 165, 255, 0.1);
}

.select-edicion:focus {
  outline: none;
  border-color: #5f76dc;
  box-shadow: 0 0 0 3px rgba(123, 165, 255, 0.2);
}

/* ===== SISTEMA DE PAGINACIÓN ===== */
.paginacion {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.02rem;
  margin-top: 1.36rem;
  padding: 1.02rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 17px rgba(0,0,0,.08);
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #f0f0f0;
}

.info-pagina {
  font-weight: 600;
  color: #374151;
  font-size: 0.77rem;
}


/* ===== MEDIA QUERIES GENERALES ===== */

/* Tablet - 768px */
@media (max-width: 768px) {
  .rutas-container {
    padding: 0 0.68rem;
    margin: 1.02rem auto;
  }
  
  .acciones {
    padding: 0.85rem;
    margin-bottom: 0.85rem;
  }
  
  .acciones h2 {
    font-size: 1.02rem;
  }
  
  .acciones > div {
    gap: 0.43rem;
  }
  
  .tabla td:last-child,
  .tabla-despachos td:last-child {
    padding: 0.34rem !important;
    min-width: 85px !important;
    max-width: 111px !important;
  }
  
  .acciones-tabla {
    min-width: 77px;
    max-width: 102px;
    gap: 0.26rem;
  }
  
  .filtros-container,
  .tabla-contenedor {
    padding: 0.85rem;
    margin-bottom: 0.85rem;
  }
  
  .estado {
    min-width: 64px;
    font-size: 0.51rem;
    padding: 0.26rem 0.51rem;
  }
  
  .input-edicion,
  .select-edicion {
    min-height: 29px;
    font-size: 0.64rem;
  }
  
  .paginacion {
    padding: 0.85rem;
    gap: 0.85rem;
  }
  
  .tabla th,
  .tabla-despachos th {
    padding: 0.51rem 0.43rem;
    font-size: 0.6rem;
  }
  
  .tabla td,
  .tabla-despachos td {
    padding: 0.51rem 0.43rem;
    font-size: 0.64rem;
  }
  
  /* Media queries específicas para formulario-ruta */
  .formulario-ruta {
    padding: 1.3rem !important;
  }
  
  .formulario-ruta .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(213px, 1fr)) !important;
    gap: 1.02rem !important;
  }
  
  .formulario-ruta .acciones-formulario {
    flex-direction: column !important;
  }
}

/* Móvil - 526px */
@media (max-width: 526px) {
  .rutas-container {
    padding: 0 0.51rem;
    margin: 0.85rem auto;
  }
  
  .acciones {
    padding: 0.68rem;
    margin-bottom: 0.68rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }
  
  .acciones h2 {
    font-size: 0.94rem;
    text-align: center;
    width: 100%;
  }
  
  .acciones > div {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.43rem;
    justify-content: center;
  }
  
  .tabla td:last-child,
  .tabla-despachos td:last-child {
    padding: 0.26rem !important;
    min-width: 68px !important;
    max-width: 85px !important;
  }
  
  .acciones-tabla {
    flex-direction: column;
    gap: 0.21rem;
    min-width: 51px;
    max-width: 68px;
    align-items: stretch;
  }
  
  .filtros-container,
  .tabla-contenedor {
    padding: 0.68rem;
    margin-bottom: 0.68rem;
  }
  
  .estado {
    min-width: 60px;
    font-size: 0.49rem;
    padding: 0.21rem 0.43rem;
  }
  
  .input-edicion,
  .select-edicion {
    min-height: 27px;
    font-size: 0.6rem;
  }
  
  .paginacion {
    flex-direction: row;
    gap: 0.68rem;
    padding: 0.68rem;
  }
  
  .tabla th,
  .tabla-despachos th {
    padding: 0.43rem 0.34rem;
    font-size: 0.55rem;
  }
  
  .tabla td,
  .tabla-despachos td {
    padding: 0.43rem 0.34rem;
    font-size: 0.6rem;
  }
  
  .search-input {
    max-width: 220px;
    height: 15px;
  }

  .search-input::placeholder {
  font-size: 0.75rem;  /* O un tamaño aún más pequeño si quieres */
  }
  
  /* Media queries específicas para formulario-ruta */
  .formulario-ruta {
    padding: 0.85rem !important;
  }
  
  .formulario-ruta .form-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }
  
  .formulario-ruta .form-grupo input,
  .formulario-ruta .form-grupo select {
    font-size: 0.72rem !important;
    padding: 0.55rem !important;
  }
  
  .formulario-ruta .acciones-formulario {
    gap: 0.43rem !important;
  }
  
  .tabla-despachos thead th:nth-child(1),
  .tabla-despachos tbody td:nth-child(1) {
    display: none !important;
  }
  
  /* Ocultar columna "Pedido" (índice 4) */
  .tabla-despachos thead th:nth-child(4),
  .tabla-despachos tbody td:nth-child(4) {
    display: none !important;
  }
  
  /* Ajustar border-radius después de ocultar columnas */
  .tabla-despachos thead tr:first-child th:nth-child(2) {
    border-top-left-radius: 7px !important;
  }
}

/* Móvil pequeño - 360px */
@media (max-width: 360px) {
  .rutas-container {
    padding: 0 0.34rem;
    margin: 0.68rem auto;
  }
  
  .acciones {
    padding: 0.6rem;
  }
  
  .acciones h2 {
    font-size: 0.85rem;
  }
  
  .tabla td:last-child,
  .tabla-despachos td:last-child {
    padding: 0.21rem !important;
    min-width: 60px !important;
    max-width: 77px !important;
  }
  
  .acciones-tabla {
    min-width: 47px;
    max-width: 60px;
    gap: 0.17rem;
  }
  
  .estado {
    min-width: 55px;
    font-size: 0.47rem;
    padding: 0.17rem 0.34rem;
  }
  
  .tabla-despachos th,
  .tabla th {
    padding: 0.34rem 0.26rem;
    font-size: 0.51rem;
  }
  
  .tabla-despachos td,
  .tabla td {
    padding: 0.34rem 0.26rem;
    font-size: 0.55rem;
  }
  
  /* Media queries específicas para formulario-ruta */
  .formulario-ruta {
    padding: 0.68rem !important;
  }
  
  .formulario-ruta .form-grupo label {
    font-size: 0.72rem !important;
  }
  
  .formulario-ruta .form-grupo input,
  .formulario-ruta .form-grupo select {
    padding: 0.51rem !important;
    font-size: 0.68rem !important;
  }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {
  .formulario-ruta .form-grupo input,
  .formulario-ruta .form-grupo select,
  .formulario-ruta .form-grupo textarea,
  .search-input {
    transition: none;
    transform: none;
  }
}