/* --- LÓGICA DE BOTONES ESTÁTICOS, RESPONSIVOS Y CAPAS CORREGIDAS --- */

/* 1. El botón principal: Ajuste perfecto al contenido, responsivo y prioridad de capa ajustada */
.btn-expandible {
    position: relative !important;
    width: fit-content !important;
    max-width: 100% !important; /* Defensa UI: Previene que el botón supere el ancho de su contenedor */
    min-width: 35px;
    height: 35px !important;
    padding: 0 12px 0 0 !important;
    display: inline-flex;
    justify-content: flex-start;
    align-items: center;
    border-radius: 50px !important;

    /* 
       CORRECCIÓN DE CAPA: 
       Bajamos a 10 para que no flote sobre menús layout (1000+), 
       pero sea superior a elementos normales del body.
    */
    z-index: 10 !important;

    overflow: hidden !important; /* Defensa UI: Corta cualquier elemento que intente salir del radio */

    /* Solo transiciones de color para feedback táctil/visual */
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, font-size 0.2s ease, height 0.2s ease !important;
}

/* El ícono como ancla visual */
.btn-expandible i {
    font-size: 1.1rem;
    margin: 0 !important;
    min-width: 35px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    transition: font-size 0.2s ease, min-width 0.2s ease;
}

/* 2. El texto: Estático, contenido y truncado seguro */
.btn-expandible .text-content {
    display: inline-flex;
    align-items: center;
    opacity: 1 !important;
    padding-left: 2px;
    font-weight: 500;
    pointer-events: none;

    /* Reglas defensivas para evitar que textos largos rompan el botón */
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: font-size 0.2s ease;
}

/* 3. Manejo de Dropdowns asociados: Estos SÍ deben ir por encima de todo */
.btn-expandible + .dropdown-menu,
.dropdown-menu.show {
    z-index: 9999 !important;
    position: absolute !important;
}

/* 4. Código defensivo para enfoque */
.btn-expandible:focus,
.btn-expandible:focus-within {
    outline: none !important;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25) !important;
    z-index: 11 !important;
}

/* ==========================================================================
   CONFIGURACIÓN DE COLORES BASE (SÓLIDOS/ESTÁTICOS)
   ========================================================================== */

/* Primary */
.btn-outline-primary.btn-expandible {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: white !important;
}

/* Secondary */
.btn-outline-secondary.btn-expandible {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: white !important;
}

/* Success (Pesables / Abonar) */
.btn-outline-success.btn-expandible,
.btn-success.btn-expandible {
    background-color: #198754 !important;
    border-color: #198754 !important;
    color: white !important;
}

/* Dark (Zonas) */
.btn-outline-dark.btn-expandible {
    background-color: #212529 !important;
    border-color: #212529 !important;
    color: white !important;
}

/* Warning (Remisiones) */
.btn-outline-warning.btn-expandible,
.btn-warning.btn-expandible {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #212529 !important;
}

.btn-outline-warning.btn-expandible i,
.btn-warning.btn-expandible i {
    color: #212529 !important;
}

/* Info (Celeste) */
.btn-outline-info.btn-expandible {
    background-color: #0dcaf0 !important;
    border-color: #0dcaf0 !important;
    color: #000 !important;
}

/* Danger (Rojo) */
.btn-outline-danger.btn-expandible {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
}

/* ==========================================================================
   ESTANDARIZACIÓN DE ALTURAS Y ALINEACIÓN (BASE ESCRITORIO)
   ========================================================================== */

.btn-expandible,
.btn-dynamic-pdf,
.btn-dynamic-xls {
    height: 35px !important;
    min-height: 35px !important;
    max-height: 35px !important;
    display: inline-flex !important;
    align-items: center !important;
}

.dropdown, .btn-group {
    position: relative;
    z-index: auto !important;
}

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

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

    .btn-expandible i {
        font-size: 1rem;
        min-width: 32px;
    }

    .btn-expandible .text-content {
        font-size: 0.85rem;
    }
}

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

    .btn-expandible i {
        font-size: 0.9rem;
        min-width: 28px;
    }

    .btn-expandible .text-content {
        font-size: 0.75rem;
        padding-left: 0px;
    }
}