/* ==========================================================================
   BOTÓN DINÁMICO EXCEL (Estático y Responsivo - VERDE)
   ========================================================================== */

/* 1. Contenedor Base */
.btn-dynamic-xls {
    position: relative !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px !important;
    height: 35px !important;
    min-width: fit-content !important;
    max-width: 100% !important; /* Defensa UI: Límite global contra desbordamiento */
    border-radius: 50px;
    border: 2px solid #198754;
    background-color: white;
    color: #198754;
    overflow: hidden !important; /* Truncamiento de seguridad */

    /* SEGURIDAD DE CAPA: Bajo el nivel del layout */
    z-index: 10 !important;

    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, height 0.2s ease !important;
}

/* Iconos */
.btn-dynamic-xls .icon-xls,
.btn-dynamic-xls .icon-arrow {
    position: relative;
    z-index: 2;
    transition: font-size 0.2s ease;
}

/* Icono Excel */
.btn-dynamic-xls .icon-xls {
    font-size: 1.2rem;
    margin-right: 5px;
}

/* Flecha */
.btn-dynamic-xls .icon-arrow {
    font-size: 1rem;
    margin-left: 5px;
}

/* Texto visible (si decides ponerlo en el HTML principal, caso contrario los iconos centran) */
.btn-dynamic-xls span:not(.icon-xls):not(.icon-arrow) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    transition: font-size 0.2s ease;
}

/* --- ESTADOS HOVER --- */
.dropdown-hover-mode:hover .btn-dynamic-xls,
.btn-dynamic-xls:hover {
    z-index: 15 !important;
    background-color: #198754;
    color: white;
}

/* ==========================================================================
   DISEÑO RESPONSIVO (ADAPTACIÓN DE DIMENSIONES)
   ========================================================================== */

/* Tablets y pantallas intermedias */
@media (max-width: 768px) {
    .btn-dynamic-xls {
        height: 32px !important;
        padding: 0 8px !important;
    }

    .btn-dynamic-xls .icon-xls { font-size: 1.1rem; margin-right: 4px; }
    .btn-dynamic-xls .icon-arrow { font-size: 0.9rem; margin-left: 4px; }
    .btn-dynamic-xls span:not(.icon-xls):not(.icon-arrow) { font-size: 0.85rem; }
}

/* Móviles en vertical */
@media (max-width: 480px) {
    .btn-dynamic-xls {
        height: 28px !important;
        padding: 0 6px !important;
    }

    .btn-dynamic-xls .icon-xls { font-size: 0.95rem; margin-right: 3px; }
    .btn-dynamic-xls .icon-arrow { font-size: 0.8rem; margin-left: 3px; }
    .btn-dynamic-xls span:not(.icon-xls):not(.icon-arrow) { font-size: 0.75rem; }
}

/* ==========================================================================
   LÓGICA PARA ABRIR EL MENÚ 
   ========================================================================== */

.dropdown-hover-mode .dropdown-menu {
    display: block;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    margin-top: 10px;
    transition: all 0.3s ease;
    transition-delay: 0.2s;
    /* CAPA MÁXIMA: Para que el menú desplegado no sea tapado por tablas o cards */
    z-index: 9999 !important;
}

/* Puente Invisible */
.dropdown-hover-mode .dropdown-menu::before {
    content: "";
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    height: 15px;
    background-color: transparent;
}

/* Estado Visible */
.dropdown-hover-mode:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    margin-top: 5px;
    transition-delay: 0s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}