/* ============================================================
   AutoDeal360 — Módulo Consulta de Inventario
   Calcado del módulo de Vehículos (misma identidad y comportamiento)
   ============================================================ */

.module-title {
  font-size: 24px;
  color: #004B94;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ----- FILTROS ----- */
.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.codigo-container  { position: relative; width: 150px; }
.search-container  { position: relative; flex-grow: 1; min-width: 220px; }

.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; }

.filter-field {
  width: 100%;
  height: 42px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  padding: 0 12px;
  box-sizing: border-box;
}

#codigoInput {
  text-transform: uppercase;
  font-family: 'Roboto Mono', monospace;
  font-weight: 500;
  letter-spacing: 1px;
  text-align: center;
}

#sugerenciasCodigo {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 100;
  display: none;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.sugerencia-codigo {
  padding: 9px 12px;
  cursor: pointer;
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
  letter-spacing: 1px;
  text-align: center;
  transition: background-color 0.2s;
  border-bottom: 1px solid #f0f0f0;
}

.sugerencia-codigo:hover { background-color: #fffbea; color: #004B94; font-weight: 600; }

/* Selects de filtros (Categoría y Estado Stock) */
.filter-select {
  height: 42px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  padding: 0 30px 0 12px;
  background-color: #fff;
  cursor: pointer;
  min-width: 175px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210%22%20height%3D%226%22%20viewBox%3D%220%200%2010%206%22%3E%3Cpath%20fill%3D%22%236c757d%22%20d%3D%22M5%206L0%200h10z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.filter-select:focus {
  outline: none;
  border-color: #004B94;
}

/* ----- BOTONES ----- */
.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; }

/* ----- 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; }

/* Variantes de estado para las stat cards de inventario */
.stat-card.warning .stat-value { color: #f59e0b; }
.stat-card.danger  .stat-value { color: #dc3545; }
.stat-card.success .stat-value { color: #198754; }

/* ----- CONTROLES DE TABLA (paginación, idéntico a vehículos) ----- */
.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; }

/* Botón Exportar (dropdown en la fila de filtros, mismo tamaño que Buscar) */
.export-dropdown .dropdown-toggle {
  height: 42px;
  padding: 10px 20px;
  font-size: 14px;
}
.export-dropdown .dropdown-toggle::after {
  margin-left: 8px;
}
.dropdown-menu  { font-size: 13px; }
.dropdown-item  { display: flex; align-items: center; gap: 8px; }
.dropdown-item i { color: #004B94; width: 14px; }

/* ----- TABLA ----- */
/* Un solo borde fino alrededor de la tabla, sin sombra propia
   (la sombra ya la aporta la card padre). Patrón visual de clientes. */
.table-wrapper {
  background: white;
  border-radius: 8px;
  box-shadow: none;
  overflow: hidden;
  border: 1px solid #e9ecef;
  margin-top: 20px;
}

.table-container { overflow-x: auto; border-radius: 8px; background: white; width: 100%; }

#inventarioTable { width: 100%; border-collapse: collapse; font-size: 14px; }

#inventarioTable 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;
}

#inventarioTable td {
  padding: 0 16px;
  height: 44px;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
}

#inventarioTable tr:nth-child(even) { background-color: #f8f9fa; }
#inventarioTable tr:hover { background-color: #fffbea; }

/* ----- 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) { .stats-bar { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
  .filters { flex-direction: column; align-items: stretch; }
  .codigo-container, .search-container, .filter-select, .export-dropdown { width: 100%; }
  .export-dropdown .dropdown-toggle { width: 100%; }
  .stats-bar { grid-template-columns: 1fr; }
  .btn-primary, .btn-secondary { width: 100%; }
}

/* ── Layout sticky (IGUAL QUE VEHÍCULOS) ── */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 15px;
    box-sizing: border-box;
    background: #f5f7fa;
}

.module-header { display: none; }

.module-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 0;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
}

.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; }

#inventarioTable { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
#inventarioTable thead { display: table; width: 100%; table-layout: fixed; }
#inventarioTable tbody {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 360px);
}
#inventarioTable tbody tr { display: table; width: 100%; table-layout: fixed; }

#inventarioTable td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Anchos de columnas (8) */
#inventarioTable th:nth-child(1), #inventarioTable td:nth-child(1) { width: 50px;  text-align: center; }
#inventarioTable th:nth-child(2), #inventarioTable td:nth-child(2) { width: 170px; }
#inventarioTable th:nth-child(3), #inventarioTable td:nth-child(3) { width: 140px; }
#inventarioTable th:nth-child(4), #inventarioTable td:nth-child(4) { width: auto;  }
#inventarioTable th:nth-child(5), #inventarioTable td:nth-child(5) { width: 160px; }
#inventarioTable th:nth-child(6), #inventarioTable td:nth-child(6) { width: 90px;  text-align: center; }
#inventarioTable th:nth-child(7), #inventarioTable td:nth-child(7) { width: 70px;  text-align: center; }
#inventarioTable th:nth-child(8), #inventarioTable td:nth-child(8) { width: 100px; text-align: center; }

/* Badge de código (igual patrón que badge de placa) */
.codigo-badge {
  display: inline-block;
  background: #004B94;
  color: #fff;
  font-family: 'Roboto Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 4px;
}

/* Estados de stock — colores estándar Bootstrap */
.stock-cero   { color: #dc3545; font-weight: 600; }
.stock-bajo   { color: #f59e0b; font-weight: 600; }
.stock-normal { color: #198754; font-weight: 600; }

/* Botón de acciones en tabla (mismo patrón que vehículos) */
.col-acciones { text-align: center; white-space: nowrap; }

.btn-ficha {
  background: none; border: none; color: #004B94; cursor: pointer;
  font-size: 16px; margin: 0 4px; padding: 2px; border-radius: 5px;
  transition: all 0.2s;
}
.btn-ficha:hover { color: #20376A; transform: scale(1.1); }