/* ============================================================
   AutoDeal360 — Módulo Vehículos
   Identidad de marca: Navy #20376A · Azul #004B94 · Amarillo #FECA05
   ============================================================ */

:root {
    --ad-navy:   #20376A;
    --ad-blue:   #004B94;
    --ad-yellow: #FECA05;
    --ad-bg:     #f5f7fa;
}

/* Reset básico (antes lo aportaba styles.css; ahora el módulo es autónomo) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

/* ── 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: var(--ad-bg);
    font-family: 'Roboto', sans-serif;
}

.card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 0;
}

/* ----- FILTROS ----- */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    margin-bottom: 10px;
}

.placa-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;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-field:focus {
    outline: none;
    border-color: var(--ad-blue);
    box-shadow: 0 0 0 3px rgba(0, 75, 148, 0.12);
}

#placaInput {
    text-transform: uppercase;
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    letter-spacing: 1px;
    text-align: center;
}

/* Sugerencias de placa */
#sugerenciasPlacas {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    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 10px rgba(0, 0, 0, 0.1);
}

.sugerencia-placa {
    padding: 9px 12px;
    cursor: pointer;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    letter-spacing: 1px;
    text-align: center;
    transition: background-color 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.sugerencia-placa:hover {
    background-color: #fffbea;
    color: var(--ad-navy);
    font-weight: 600;
}

/* ----- BOTONES ----- */
.btn-primary, .btn-secondary {
    padding: 0 20px;
    height: 42px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    border: none;
}

.btn-primary {
    background-color: var(--ad-blue);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--ad-navy);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(32, 55, 106, 0.25);
}

.btn-secondary {
    background-color: #fff;
    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: 10px 0;
    flex-shrink: 0;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
    border: 1px solid #e9ecef;
    border-top: 3px solid var(--ad-yellow);
    transition: all 0.25s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.stat-value {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: var(--ad-navy);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* ----- CONTROLES DE PAGINACIÓN ----- */
.table-controls {
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.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;
    font-size: 14px;
    color: #495057;
}

.rows-per-page select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #495057;
}

.page-btn {
    padding: 6px 10px;
    min-width: 32px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    color: var(--ad-navy);
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: var(--ad-navy);
    color: #fff;
    border-color: var(--ad-navy);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ----- TABLA ----- */
.table-wrapper {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-top: 10px;
    flex-shrink: 0;
}

.table-container {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#vehiculosTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

#vehiculosTable {
    display: flex;
    flex-direction: column;
}

#vehiculosTable thead {
    display: table;
    width: 100%;
    table-layout: fixed;
    flex-shrink: 0;
}

#vehiculosTable th {
    background: var(--ad-navy);
    color: #fff;
    padding: 13px 14px;
    text-align: left;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

#vehiculosTable tbody {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    /* La altura la fija dinámicamente el JS (ajustarAlturaTabla) a 10 filas
       exactas. Este valor es solo un respaldo inicial mientras carga. */
    height: 520px;
}

#vehiculosTable tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

#vehiculosTable td {
    padding: 11px 14px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#vehiculosTable tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

#vehiculosTable tbody tr:hover {
    background-color: #fffbea;
}

/* Anchos de columna (12 columnas) */
#vehiculosTable th:nth-child(1),  #vehiculosTable td:nth-child(1)  { width: 45px;  text-align: center; } /* # */
#vehiculosTable th:nth-child(2),  #vehiculosTable td:nth-child(2)  { width: 90px;  } /* Placa */
#vehiculosTable th:nth-child(3),  #vehiculosTable td:nth-child(3)  { width: 140px; } /* VIN */
#vehiculosTable th:nth-child(4),  #vehiculosTable td:nth-child(4)  { width: 110px; } /* N° Motor */
#vehiculosTable th:nth-child(5),  #vehiculosTable td:nth-child(5)  { width: 55px;  } /* Año */
#vehiculosTable th:nth-child(6),  #vehiculosTable td:nth-child(6)  { width: 90px;  } /* Color */
#vehiculosTable th:nth-child(7),  #vehiculosTable td:nth-child(7)  { width: 110px; } /* Marca */
#vehiculosTable th:nth-child(8),  #vehiculosTable td:nth-child(8)  { width: 110px; } /* Modelo */
#vehiculosTable th:nth-child(9),  #vehiculosTable td:nth-child(9)  { width: 90px;  } /* V. RTV */
#vehiculosTable th:nth-child(10), #vehiculosTable td:nth-child(10) { width: 90px;  } /* V. SOAT */
#vehiculosTable th:nth-child(11), #vehiculosTable td:nth-child(11) { width: 150px; } /* Cliente */
#vehiculosTable th:nth-child(12), #vehiculosTable td:nth-child(12) { width: 90px; text-align: center; } /* Acciones */

/* Badge de placa */
.placa-badge {
    display: inline-block;
    background: var(--ad-navy);
    color: #fff;
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
}

/* Fechas vencidas (RTV / SOAT) */
.fecha-vencida {
    color: #dc3545 !important;
    font-weight: 600;
}

.fecha-vencida::after {
    content: ' \f071';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
}

/* ----- BOTONES DE ACCIÓN EN TABLA ----- */
.col-acciones {
    text-align: center;
    white-space: nowrap;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    margin: 0 4px;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.2s;
    color: var(--ad-blue);
}

.action-btn:hover {
    transform: scale(1.15);
}

.btn-historial:hover {
    color: var(--ad-navy);
    background: rgba(32, 55, 106, 0.08);
}

.btn-ficha:hover {
    color: var(--ad-navy);
    background: rgba(254, 202, 5, 0.18);
}

/* ----- LOADING ----- */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9998;
}

.loading-content {
    text-align: center;
    color: var(--ad-navy);
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid var(--ad-blue);
    width: 42px;
    height: 42px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@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; }
    .placa-container, .search-container { width: 100%; }
    .stats-bar { grid-template-columns: 1fr 1fr; }
    .btn-primary, .btn-secondary { width: 100%; }
}