/* ==============================================================
   🎨 VARIABLES GLOBALES
============================================================== */
:root {
    --primary-color: #3b7ddd;
}

*, *::before, *::after {
    box-sizing: border-box;
}
/* ==============================================================
   🌐 1. REGLA UNIVERSAL DE AUTO-AJUSTE FLUIDO (LIQUID LAYOUT) 🌐
============================================================== */
.hero-panel,
.hero-panel .d-flex,
.hero-panel .row {
    flex-wrap: wrap !important;
    max-width: 100% !important;
    gap: 15px;
}

/* Comportamiento inteligente de las cajas (Buscador, Excel, Dropzone) */
/* Se eliminó .d-flex.gap-3>div para evitar que rompa columnas verticales */
.hero-panel>div,
.hero-panel form,
.upload-box {
    flex: 1 1 300px !important;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Seguridad total: El contenedor principal NUNCA debe ser más ancho que la pantalla */
.content-modern,
main,
.container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    /* Cambiado a 100% */
    box-sizing: border-box !important;
}

.hero-panel {
    width: 100%;
    overflow: hidden;
}

/* ==============================================================
   ↕️ 2. FIX PARA SCROLL VERTICAL EN EL MENÚ LATERAL (SIDEBAR) ↕️
============================================================== */

/* 1. Aseguramos que la barra lateral mida exactamente la pantalla completa */
.sidebar {
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
}

/* 2. LA CURA CONTRA EL PLUGIN DE SCROLL (SimpleBar)
   Forzamos a todos los divs invisibles que inyecta el JS a que transmitan la altura
   y se comporten como una columna. */
.sidebar-content,
.simplebar-wrapper,
.simplebar-mask,
.simplebar-offset,
.simplebar-content-wrapper,
.simplebar-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 100% !important;
    flex-grow: 1 !important;
}

/* 3. El contenedor de los enlaces (Inicio, Tablas, Usuarios...) 
   Este es el ÚNICO que tendrá permiso de hacer scroll */
.sidebar-nav {
    flex-grow: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-bottom: 20px !important;
    overscroll-behavior: contain;
    
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* 4. La sección de Cuenta (Fija hasta abajo) */
/* (Nota: Usa .sidebar-bottom o .sidebar-cta dependiendo de cómo le llamaste en tu HTML) */
.sidebar-bottom,
.sidebar-cta {
    flex-shrink: 0 !important;
    /* Evita que se aplaste */
    margin-top: auto !important;
    /* Lo empuja automáticamente hacia el fondo */
    background: #162a4d !important;
    /* Fondo para que tape los enlaces que pasan por detrás */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 20px;
    z-index: 10;
}

/* 5. Diseño Naval de la barrita de scroll del menú */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ==============================================================
   ↔️ 3. FIX PARA SCROLL HORIZONTAL Y BARRA PERSONALIZADA ↔️
============================================================== */
.content-modern {
    overflow-x: hidden !important;
}

.data-table-wrapper {
    overflow-x: auto !important;
    width: 100%;
    max-width: 100%;
    display: block;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;

    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

table.as-table {
    min-width: 1100px;
    width: 100%;
}

.data-table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.data-table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.data-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
}

.data-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.45);
}

/* ==============================================================
   ⚙️ 4. ESTILOS DEL PANEL ADMINKIT PRO (CONFIGURACIÓN) ⚙️
============================================================== */
.btn-theme-config {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 1080;
    transition: transform 0.3s ease;
    background-color: var(--primary-color) !important;
    border: none;
    color: white;
}

.btn-theme-config:hover {
    transform: scale(1.1);
}

.fa-spin-hover:hover {
    animation: fa-spin 2s infinite linear;
}

.panel-configuracion-pro {
    background-color: #222e3c !important;
    color: #e9ecef;
    width: 340px;
    border-left: none;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.alert-custom {
    background-color: #1a3b5c;
    color: #e9ecef;
    border: 1px solid rgba(59, 125, 221, 0.3);
    font-size: 0.85rem;
    padding: 12px 15px;
    border-radius: 4px;
}

.config-group {
    margin-bottom: 10px;
}

.config-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: #ced4da;
}

.config-subtitle {
    font-size: 0.75rem;
    color: #8a98a8;
    margin-bottom: 12px;
}

.config-divider {
    border-color: rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

.theme-box {
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-box:hover {
    border-color: rgba(255, 255, 255, 0.4);
}

.theme-box.active {
    border-color: var(--primary-color);
    background-color: rgba(59, 125, 221, 0.05);
}

.theme-box span {
    font-size: 0.8rem;
    font-weight: 500;
    display: block;
    margin-top: 10px;
}

.theme-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin: 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.circle-default {
    background: linear-gradient(135deg, #ffffff 50%, #222e3c 50%);
}

.circle-colored {
    background: linear-gradient(135deg, #ffffff 50%, var(--primary-color) 50%);
}

.circle-dark {
    background: #222e3c;
    border: 2px solid #6c757d;
}

.circle-light {
    background: #ffffff;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-sq {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.color-sq:hover {
    transform: scale(1.1);
}

.color-sq i {
    color: white;
    font-size: 12px;
    display: none;
}

.color-sq.active i {
    display: block;
}

.btn-group .btn-config {
    background-color: #343a40;
    color: #adb5bd;
    border: 1px solid transparent;
    font-size: 0.85rem;
    padding: 6px 12px;
}

.btn-group .btn-config:hover {
    background-color: #495057;
    color: white;
}

.btn-group .btn-config.active {
    background-color: var(--primary-color);
    color: white;
}

/* ==============================================================
   📱 5. RESPONSIVIDAD TOTAL (PC, LAPTOPS, TABLETS Y MÓVILES) 📱
============================================================== */

/* 🖥️ PANTALLAS GIGANTES Y ULTRAWIDES (min-width: 1400px) */
@media (min-width: 1400px) {
    .container-fluid {
        max-width: 1600px;
        margin: 0 auto;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    table.as-table td {
        font-size: 14px;
    }
}

/* 💻 LAPTOPS PEQUEÑAS Y TABLETS EN HORIZONTAL (hasta 1199.98px) */
@media (max-width: 1199.98px) {
    .hero-panel {
        padding: 24px;
    }

    .upload-box {
        padding: 25px 15px;
    }

    .modal-dialog {
        max-width: 95%;
        margin: 1.5rem auto;
    }
}

/* 📱 TABLETS PORTRAIT Y DISPOSITIVOS MEDIANOS (hasta 991.98px) */
@media (max-width: 991.98px) {
    .content-modern {
        padding: 15px !important;
    }

    .hero-panel {
        padding: 20px !important;
        margin-bottom: 15px;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    .d-flex.align-items-end.gap-3.flex-wrap {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .d-flex.align-items-end.gap-3.flex-wrap>div {
        width: 100%;
    }

    .btn-excel {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }

    .d-flex.align-items-center.justify-content-between.flex-wrap.gap-3 {
        flex-direction: column;
        align-items: stretch !important;
        text-align: center;
    }

    .toolbar-info,
    .toolbar-pagination {
        width: 100%;
        justify-content: center;
    }

    /* Ajustes específicos para Modales en Tablets */
    .modal-header .d-flex,
    .modal-header .btn-group {
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: flex-start;
        margin-top: 10px;
    }

    .modal-header .btn {
        font-size: 0.8rem;
        padding: 5px 10px;
    }

    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 4px;
        margin-bottom: 15px;
    }

    .nav-tabs::-webkit-scrollbar {
        height: 4px;
    }

    .nav-tabs::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
    }

    .modal-body {
        max-height: 60vh;
        overflow-y: auto !important;
        padding: 15px;
    }

    .modal-body::-webkit-scrollbar {
        width: 6px;
    }

    .modal-body::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.25);
        border-radius: 10px;
    }
}

/* 📱 CELULARES HORIZONTALES Y TABLETS PEQUEÑAS (hasta 767.98px) */
@media (max-width: 767.98px) {
    .sidebar {
        z-index: 1070 !important;
    }

    .navbar {
        padding: 0.5rem 1rem !important;
    }

    .data-table-wrapper {
        padding-bottom: 10px;
    }

    table.as-table th {
        font-size: 11px;
        padding: 10px 8px;
    }

    table.as-table td {
        font-size: 12px;
        padding: 8px;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .pagination .page-link {
        padding: 0.4rem 0.6rem;
        font-size: 12px;
    }

    .upload-box {
        padding: 15px;
    }

    .upload-content i {
        font-size: 35px;
        margin-bottom: 8px;
    }

    .upload-content h5 {
        font-size: 1rem;
    }

    /* Ajustes específicos para Modales en Celulares */
    .modal-body .row>[class*="col-"] {
        width: 100% !important;
        margin-bottom: 15px;
    }

    .modal-body .text-center {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
}

/* 📱 CELULARES VERTICALES PEQUEÑOS (hasta 575.98px) */
@media (max-width: 575.98px) {
    .content-modern {
        padding: 10px !important;
    }

    .hero-panel {
        padding: 15px !important;
    }

    .hero-title {
        font-size: 1.35rem;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 0.8rem;
        margin-top: 8px;
    }

    .card {
        padding: 15px !important;
    }

    .toolbar-info,
    #totalResultados,
    #infoPaginacionPuesto {
        font-size: 12px;
        text-align: center;
        display: block;
        width: 100%;
        margin-bottom: 8px;
    }

    .modal-header h5 {
        font-size: 1.1rem;
    }

    .funciones-container {
        max-height: 80px;
    }
}