/* Estilos generales para el módulo de Clientes */
.module-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e0e0e0;
}

.module-title {
  font-size: 24px;
  color: #004B94;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 20px;
  margin-bottom: 20px;
}

/* ----- ESTILOS PARA FILTROS ----- */
.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.filter-btn {
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background-color: white;
  color: #495057;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: all 0.3s;
}

.filter-btn:hover {
  background-color: #f8f9fa;
  border-color: #ced4da;
}

.filter-btn.active {
  background-color: #004B94;
  color: white;
  border-color: #004B94;
}

/* ----- CAMPO DE BÚSQUEDA ----- */
.search-container {
  position: relative;
  flex-grow: 1;
}

.search-container::before {
  content: '\f002';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  font-size: 14px;
  pointer-events: none;
}

#busquedaInput {
  padding-left: 35px;
  width: 100%;
  height: 42px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

/* Sugerencias de búsqueda */
#sugerenciasBusqueda {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 0 0 4px 4px;
  z-index: 100;
  display: none;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.sugerencia-busqueda {
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.sugerencia-busqueda:hover {
  background-color: #f1f7ff;
}

/* ----- BOTONES ----- */
#buscarBtn, #limpiarBtn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  height: 42px;
}

#buscarBtn {
  background-color: #004B94;
  color: white;
}

#buscarBtn:hover {
  background-color: #20376A;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(67, 97, 238, 0.2);
}

#limpiarBtn {
  background-color: white;
  border: 1px solid #ddd;
  color: #495057;
}

#limpiarBtn:hover {
  background-color: #f8f9fa;
  border-color: #ced4da;
}

/* ----- ESTADÍSTICAS ----- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  text-align: center;
  border: 1px solid #e9ecef;
  transition: all 0.3s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #004B94;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 13px;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* ----- TABLA ----- */
.table-wrapper {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  overflow: hidden;
  border: 1px solid #e9ecef;
  margin-top: 20px;
}

.table-container {
  overflow-x: auto;
  border-radius: 8px;
  background: white;
  width: 100%;
}

#clientesTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#clientesTable th {
  background: #004B94;
  color: white;
  padding: 14px 16px;
  text-align: left;
  position: sticky;
  top: 0;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.5px;
}

#clientesTable td {
  padding: 12px 16px;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
}

#clientesTable tr:nth-child(even) {
  background-color: #f8f9fa;
}

#clientesTable tr:hover {
  background-color: #fffbea;
}

/* Acciones */
.action-btn {
  background: none;
  border: none;
  color: #004B94;
  cursor: pointer;
  font-size: 16px;
  margin: 0 5px;
  transition: all 0.2s;
}

.action-btn:hover {
  color: #20376A;
  transform: scale(1.1);
}

/* ----- PAGINACIÓN ----- */
.table-controls {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e9ecef;
}

.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.rows-per-page {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rows-per-page select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-btn {
  padding: 6px 10px;
  min-width: 32px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ----- MODAL ----- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  padding: 25px;
  border-radius: 8px;
  width: 80%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.close-modal {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
}

.close-modal:hover {
  color: #dc3545;
}

/* ----- LOADING ----- */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255,255,255,0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top: 4px solid #004B94;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ----- RESPONSIVE ----- */
@media (max-width: 992px) {
  .filters {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .filters {
    grid-template-columns: 1fr;
  }
  
  .filter-group {
    flex-direction: column;
  }
  
  .stats-bar {
    grid-template-columns: 1fr;
  }
  
  #buscarBtn, #limpiarBtn {
    width: 100%;
  }
}

/* Modal moderno */
.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 25px;
    border-radius: 12px;
    width: 55%;
    max-width: 650px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 5px 30px rgba(0,0,0,0.3);
    border: none;
    position: relative;
}

.modal-content h2 {
    color: #004B94;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#clienteInfoModal {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 15px;
    border-left: 4px solid #004B94;
}

#placasTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 15px;
}

#placasTable th {
    background: #004B94;
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

#placasTable td {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
}

#placasTable tr:nth-child(even) {
    background-color: #f8f9fa;
}

#placasTable tr:hover {
    background-color: #f1f7ff;
}

.close-modal {
    position: absolute;
    right: 25px;
    top: 25px;
    font-size: 28px;
    color: #aaa;
    cursor: pointer;
    transition: all 0.3s;
}

.close-modal:hover {
    color: #333;
    transform: rotate(90deg);
}
/* Agregar al CSS */
.modal-content {
    transition: opacity 0.3s;
}
.modal-loading {
    opacity: 0.7;
    pointer-events: none;
}


/* ── Layout sticky: filtros fijos, scroll solo en tabla ── */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 15px;
    box-sizing: border-box;
    background: #f5f7fa;
}

.module-header {
    display: none;
}

.card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 0;
}

.filters    { flex-shrink: 0; }
.stats-bar  { flex-shrink: 0; margin: 10px 0; }
.table-controls { flex-shrink: 0; }

.table-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin-top: 10px;
}

.table-container {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Tabla con layout fijo para alinear thead y tbody */
#clientesTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

#clientesTable thead {
    display: table;
    width: 100%;
    table-layout: fixed;
}

#clientesTable tbody {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 320px);
}

#clientesTable tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Anchos de columnas */
#clientesTable th:nth-child(1),
#clientesTable td:nth-child(1) { width: 55px;  text-align: center; } /* # */
#clientesTable th:nth-child(2),
#clientesTable td:nth-child(2) { width: 65px;  } /* Tipo DOI */
#clientesTable th:nth-child(3),
#clientesTable td:nth-child(3) { width: 100px; } /* N° DOI */
#clientesTable th:nth-child(4),
#clientesTable td:nth-child(4) { width: 160px; } /* Nombre / Propietario */
#clientesTable th:nth-child(5),
#clientesTable td:nth-child(5) { width: 140px; } /* Dirección */
#clientesTable th:nth-child(6),
#clientesTable td:nth-child(6) { width: 90px;  } /* Distrito */
#clientesTable th:nth-child(7),
#clientesTable td:nth-child(7) { width: 85px;  } /* Provincia */
#clientesTable th:nth-child(8),
#clientesTable td:nth-child(8) { width: 95px;  } /* Departamento */
#clientesTable th:nth-child(9),
#clientesTable td:nth-child(9) { width: 100px; } /* Celular */
#clientesTable th:nth-child(10),
#clientesTable td:nth-child(10){ width: 170px; } /* Email */
#clientesTable th:nth-child(11),
#clientesTable td:nth-child(11){ width: 70px;  text-align: center; } /* Acciones */

/* Truncar texto largo */
#clientesTable td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Anchos específicos para EMPRESA (10 columnas) */
.tipo-empresa #clientesTable th:nth-child(1),
.tipo-empresa #clientesTable td:nth-child(1) { width: 55px;  text-align: center; } /* # */
.tipo-empresa #clientesTable th:nth-child(2),
.tipo-empresa #clientesTable td:nth-child(2) { width: 65px;  } /* Tipo DOI */
.tipo-empresa #clientesTable th:nth-child(3),
.tipo-empresa #clientesTable td:nth-child(3) { width: 110px; } /* N° RUC */
.tipo-empresa #clientesTable th:nth-child(4),
.tipo-empresa #clientesTable td:nth-child(4) { width: 200px; } /* Propietario */
.tipo-empresa #clientesTable th:nth-child(5),
.tipo-empresa #clientesTable td:nth-child(5) { width: 150px; } /* Dir. Fiscal */
.tipo-empresa #clientesTable th:nth-child(6),
.tipo-empresa #clientesTable td:nth-child(6) { width: 90px;  } /* Distrito */
.tipo-empresa #clientesTable th:nth-child(7),
.tipo-empresa #clientesTable td:nth-child(7) { width: 85px;  } /* Provincia */
.tipo-empresa #clientesTable th:nth-child(8),
.tipo-empresa #clientesTable td:nth-child(8) { width: 95px;  } /* Departamento */
.tipo-empresa #clientesTable th:nth-child(9),
.tipo-empresa #clientesTable td:nth-child(9) { width: 110px; } /* Encargado */
.tipo-empresa #clientesTable th:nth-child(10),
.tipo-empresa #clientesTable td:nth-child(10){ width: 160px; } /* Email Encargado */
.tipo-empresa #clientesTable th:nth-child(11),
.tipo-empresa #clientesTable td:nth-child(11){ width: 110px; } /* Celular Encargado */
.tipo-empresa #clientesTable th:nth-child(12),
.tipo-empresa #clientesTable td:nth-child(12){ width: 70px;  text-align: center; } /* Acciones */
/* ── Modal placas: ícono amarillo en título ── */
.modal-content h2 i {
    color: #FECA05;
}

/* ── Modal placas: tabla con scroll y bordes redondeados ── */
.modal-body .table-container {
    max-height: 400px;
    overflow: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

#placasTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

#placasTable thead {
    display: table;
    width: 100%;
    table-layout: fixed;
}

#placasTable thead th:first-child { border-radius: 8px 0 0 0; }
#placasTable thead th:last-child  { border-radius: 0 8px 0 0; }

#placasTable tbody {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 340px;
}

#placasTable tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

#placasTable tbody tr:last-child td:first-child { border-radius: 0 0 0 8px; }
#placasTable tbody tr:last-child td:last-child  { border-radius: 0 0 8px 0; }

/* Columnas placas modal */
#placasTable th:nth-child(1),
#placasTable td:nth-child(1) { width: 40px;  text-align: center; } /* # */
#placasTable th:nth-child(2),
#placasTable td:nth-child(2) { width: 80px;  } /* Placa */
#placasTable th:nth-child(3),
#placasTable td:nth-child(3) { width: 50px;  } /* Año */
#placasTable th:nth-child(4),
#placasTable td:nth-child(4) { width: 100px; } /* Color */
#placasTable th:nth-child(5),
#placasTable td:nth-child(5) { width: 100px; } /* Marca */
#placasTable th:nth-child(6),
#placasTable td:nth-child(6) { width: 100px; } /* Modelo */
#placasTable th:nth-child(7),
#placasTable td:nth-child(7) { width: 80px; text-align: center; white-space: nowrap; } /* Acciones */
/* ----- BOTÓN CREAR + clases base de botones (para igualar a vehículos) ----- */
.btn-primary, .btn-secondary {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  height: 42px;
}
.btn-primary { background-color: #004B94; color: white; }
.btn-primary:hover { background-color: #20376A; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(67,97,238,0.2); }
.btn-secondary { background-color: white; border: 1px solid #ddd; color: #495057; }
.btn-secondary:hover { background-color: #f8f9fa; border-color: #ced4da; }

.btn-crear { background-color: #198754; }
.btn-crear:hover { background-color: #146c43; }

/* La búsqueda se estira; los botones quedan compactos a la derecha */
.search-container { flex-grow: 1; min-width: 220px; }

/* ----- MODAL CREAR (iframe) ----- */
.crear-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
}
.crear-modal-overlay.show { display: flex; }

.crear-modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.crear-modal-header {
  background: #20376A;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.crear-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.crear-modal-title i { color: #FECA05; }

.crear-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color .2s, transform .2s;
}
.crear-modal-close:hover { color: #f72585; transform: rotate(90deg); }

.crear-modal-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}