/**
 * VARIABLES GLOBALES
 * Se centralizan los colores para facilitar cambios de marca rápidos.
 */
:root {
    --primary-blue: #000B41;
    --accent-lime: #CDDC39;
    --bg-gray: #f8f9fa;
    --text-main: #212529;
    --error-bg: #f8d7da;
    --error-text: #721c24;
    --error-border: #842029; 
    --loader-bg: rgba(255, 255, 255, 0.9);
}

body { 
    font-family: 'Segoe UI', system-ui, sans-serif; 
    background-color: var(--bg-gray); 
    margin-top: 20px; 
    color: var(--text-main);
}

/**
 * BANNER DE ERROR
 */
#errorVisual {
    width: 100%;
    background-color: var(--error-bg);
    color: var(--error-text);
    padding: 16px;
    text-align: center;
    font-weight: 600;
    border-bottom: 4px solid var(--error-border); 
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10001;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* NAVEGACIÓN POR PESTAÑAS */
.nav-tabs { border: none; margin-bottom: 30px; justify-content: center; }
.nav-tabs .nav-link { color: #666; border: none; padding: 10px 30px; font-weight: 500; }
.nav-tabs .nav-link.active { 
    color: var(--primary-blue); 
    border-bottom: 4px solid var(--accent-lime); 
    background: none; 
    font-weight: bold; 
}

.section-header { 
    color: var(--primary-blue); 
    text-align: center; 
    text-transform: uppercase; 
    margin-bottom: 30px; 
    font-weight: 700; 
}

/**
 * CONTENEDOR DE BÚSQUEDA
 */
.search-container { 
    width: 100%;
    max-width: 100% !important; 
    margin: 0 auto 40px auto; 
    background: white; 
    padding: 20px 30px; 
    border-radius: 12px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); 
    position: relative;
}

.search-flex-container { 
    display: flex; 
    flex-direction: row; 
    align-items: flex-end; 
    gap: 15px; 
    justify-content: center; 
    flex-wrap: nowrap; 
}

/* CONTROL DE DIMENSIONES (Escritorio) */
.item-servicio, .item-ruta { flex: 0 1 280px; min-width: 200px; }
.item-destino { flex: 0 1 220px; min-width: 180px; }
.item-registros { flex: 0 1 100px; min-width: 80px; }
.item-boton { flex: 0 1 160px; min-width: 140px; }

/**
 * CUSTOMIZACIÓN DE SELECT2
 */
.select2-container--default .select2-selection--single {
    height: 38px !important;
    border: 1px solid #ced4da !important;
    border-radius: 6px !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px !important;
    padding-left: 12px !important;
    font-size: 0.9rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px !important;
}
.select2-results__options {
    max-height: 250px !important; 
    font-size: 0.9rem;
}

.custom-select { 
    border: 1px solid #ced4da; 
    border-radius: 6px; 
    height: 38px; 
    font-size: 0.9rem;
}

/**
 * TABLAS Y BOTONES
 */
.btn-consultar { 
    background-color: var(--primary-blue); 
    color: white; 
    height: 38px; 
    font-weight: 600; 
    border-radius: 6px; 
    border: none; 
    transition: all 0.3s ease;
    font-size: 0.8rem;
    text-transform: uppercase;
    width: 100%;
}
.btn-consultar:hover { background-color: #001a8c; color: white; }

.table-custom { background: white; font-size: 0.85rem; width: 100% !important; }
.table-custom thead th { 
    background-color: #f1f1f1; 
    color: var(--primary-blue);
    text-align: center !important; 
    vertical-align: middle;
    text-transform: uppercase; 
    font-size: 0.75rem; 
    border-bottom: 2px solid var(--accent-lime);
}
.table-custom tbody td { text-align: center !important; vertical-align: middle; }

/**
 * PAGINACIÓN
 */
.pagination-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 50px;
    padding: 15px 25px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.btn-page { 
    background-color: #f8f9fa; 
    color: var(--text-main); 
    border: 1px solid #dee2e6; 
    padding: 5px 15px; 
    text-decoration: none; 
    border-radius: 4px; 
    font-size: 0.85rem;
}
.btn-page:hover:not(.disabled) { background-color: var(--accent-lime); color: black; }
.btn-page.disabled { opacity: 0.5; cursor: not-allowed; }

/**
 * RESPONSIVIDAD (Media Queries corregidas)
 * Cubre Tablets (iPad) y Celulares
 */
@media (max-width: 992px) {
    .search-flex-container { 
        flex-wrap: wrap; 
        justify-content: space-between;
    }
    
    /* Forzamos 2 elementos por fila en Tablet */
    .item-servicio, .item-ruta, .item-destino, .item-registros { 
        flex: 1 1 48% !important; 
        margin-bottom: 10px;
    }
    
    /* El botón ocupa todo el ancho abajo para mejor acceso táctil */
    .item-boton { 
        flex: 1 1 100% !important; 
        margin-top: 5px;
    }

    .pagination-box { 
        flex-direction: column !important; 
        gap: 12px; 
        padding: 15px !important; 
        font-size: 11px !important; 
    }
}

/* Ajuste para celulares pequeños */
@media (max-width: 576px) {
    .item-servicio, .item-ruta, .item-destino, .item-registros { 
        flex: 1 1 100% !important; /* 1 por fila en celular */
    }
}

/**
 * LOADER GLOBAL
 */
#loader-global {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.93);
    z-index: 99999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 120px;
    height: 120px;
    border: 10px solid #000B41;
    border-bottom-color: #CDDC39;
    border-radius: 50%;
    animation: rotation 1s linear infinite;
}

#loader-global p {
    margin-top: 30px;
    font-size: 24px;
    font-weight: 700;
    color: #000B41;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}