/* Contenedor del botón dinámico */
.btn-dynamic-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    height: 35px; /* Altura fija para mantener el centro */
    min-width: 35px; /* Empieza como círculo */
    border-radius: 50px; /* Bordes totalmente redondos */
    border: 2px solid #dc3545; /* Rojo Bootstrap (btn-outline-danger) */
    background-color: white;
    color: #dc3545;
    transition: all 0.4s ease; /* Suavidad de la animación */
    overflow: hidden;
    position: relative;
    font-weight: bold;
}

/* Icono PDF (Siempre visible) */
.btn-dynamic-pdf .icon-pdf {
    font-size: 1.2rem;
    margin-left: 11px; /* Ajuste visual para centrar en modo círculo */
    transition: margin 0.4s ease;
}

/* Texto "Exportar" (Oculto inicialmente) */
.btn-dynamic-pdf .text-label {
    max-width: 0;
    opacity: 0;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.4s ease;
    margin-left: 0;
}

/* Flecha (Visible inicialmente) */
.btn-dynamic-pdf .icon-arrow {
    font-size: 1rem;
    margin-left: 5px;
    margin-right: 11px; /* Ajuste visual */
    opacity: 1;
    max-width: 20px;
    transition: all 0.3s ease;
}

/* --- ESTADO HOVER (Cuando el mouse pasa por encima) --- */

/* 1. Cambios en el contenedor (se hace rojo y ancho) */
.dropdown:hover .btn-dynamic-pdf,
.btn-dynamic-pdf:hover {
    background-color: #dc3545;
    color: white;
    padding-right: 15px; /* Espacio para el texto */
    padding-left: 5px;
}

/* 2. El icono PDF se mueve un poco */
.dropdown:hover .btn-dynamic-pdf .icon-pdf,
.btn-dynamic-pdf:hover .icon-pdf {
    margin-left: 0;
}

/* 3. Aparece el texto */
.dropdown:hover .btn-dynamic-pdf .text-label,
.btn-dynamic-pdf:hover .text-label {
    max-width: 100px; /* Suficiente para mostrar "Exportar" */
    opacity: 1;
    margin-left: 8px;
}

/* 4. Desaparece la flecha */
.dropdown:hover .btn-dynamic-pdf .icon-arrow,
.btn-dynamic-pdf:hover .icon-arrow {
    opacity: 0;
    max-width: 0;
    margin: 0;
}

/* --- LÓGICA PARA ABRIR EL MENÚ (MEJORADA) --- */

/* 1. Configuración base del menú (Oculto pero "existente") */
.dropdown-hover-mode .dropdown-menu {
    display: block; /* Siempre renderizado para poder animar */
    opacity: 0;
    visibility: hidden;

    /* Posición inicial un poco más abajo para efecto de subida */
    transform: translateY(10px);
    margin-top: 10px; /* El espacio visual entre botón y menú */

    /* TRANSICIÓN CLAVE: */
    /* Cuando quitamos el mouse, tarda 0.3s en desaparecer (transition-delay) */
    transition: all 0.3s ease;
    transition-delay: 0.2s; /* <--- ESTO TE DA EL TIEMPO QUE NECESITAS */
}

/* 2. El "Puente Invisible" */
/* Esto crea una capa transparente entre el botón y el menú */
.dropdown-hover-mode .dropdown-menu::before {
    content: "";
    position: absolute;
    top: -15px; /* Sube para tocar el botón */
    left: 0;
    width: 100%;
    height: 15px; /* Altura suficiente para cubrir el hueco */
    background-color: transparent; /* Invisible */
    /* background-color: rgba(255,0,0,0.2); Descomenta esto para VER el puente si quieres depurar */
}

/* 3. Estado HOVER (Cuando el mouse está encima del botón O del menú) */
.dropdown-hover-mode:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    margin-top: 5px; /* Posición final */

    /* Cuando ENTRAS, no hay delay, aparece al instante */
    transition-delay: 0s;
}

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