/**
 * AyudaWP Desplegables - Estilos
 *
 * @package AyudaWP_Desplegables
 * @version 1.1.0
 */

/* ==============================================
   CONTENEDOR PRINCIPAL
   ============================================== */
.ayudawp-desplegables-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
    box-sizing: border-box;
}

/* ==============================================
   CADA DESPLEGABLE
   ============================================== */
.ayudawp-desplegable {
    flex: 1 1 300px;
    min-width: 250px;
    max-width: 100%;
    position: relative;
    box-sizing: border-box;
}

/* Desplegable individual (shortcodes separados) */
.ayudawp-desplegable-single .ayudawp-desplegable {
    flex: 1 1 100%;
    max-width: 400px;
}

/* ==============================================
   BOTON TOGGLE (TITULO DEL DESPLEGABLE)
   ============================================== */
.ayudawp-desplegable-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    background-color: #ffffff;
    color: inherit;
    font-family: inherit;
    font-size: 1em;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    box-sizing: border-box;
}

.ayudawp-desplegable-toggle:hover,
.ayudawp-desplegable-toggle:focus {
    background-color: #f5f5f5;
    outline: none;
}

.ayudawp-desplegable-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Titulo del desplegable */
.ayudawp-desplegable-title {
    flex: 1;
}

/* Icono flecha */
.ayudawp-desplegable-icon {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

/* Icono rotado cuando esta abierto */
.ayudawp-desplegable-toggle[aria-expanded="true"] .ayudawp-desplegable-icon {
    transform: rotate(-135deg);
}

/* ==============================================
   CONTENIDO DEL DESPLEGABLE (CAJA DESPLEGADA)
   ============================================== */
.ayudawp-desplegable-content {
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 200px;
    margin-top: 4px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    box-sizing: border-box;
}

/* Altura especifica para el desplegable de etiquetas */
.ayudawp-desplegable[data-desplegable="etiquetas"] .ayudawp-desplegable-content {
    max-height: 90vh;
}

.ayudawp-desplegable-content[hidden] {
    display: none;
}

/* ==============================================
   LISTA DE ITEMS
   ============================================== */
.ayudawp-desplegable-list {
    list-style: none;
    margin: 0 !important;
    padding: 4px 0;
}

.ayudawp-desplegable-list li {
    margin: 0 !important;
    padding: 0;
}

/* ==============================================
   CADA ITEM (ENLACE)
   ============================================== */
.ayudawp-desplegable-list li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.ayudawp-desplegable-list li a:hover,
.ayudawp-desplegable-list li a:focus {
    background-color: rgba(0, 0, 0, 0.05);
    text-decoration: none;
}

/* Contador de posts */
.ayudawp-desplegable-count {
    flex-shrink: 0;
    margin-left: 8px;
    font-size: 0.85em;
    opacity: 0.7;
}

/* Mensaje sin items */
.ayudawp-desplegable-no-items {
    padding: 16px;
    margin: 0;
    text-align: center;
    font-style: italic;
    opacity: 0.7;
}

/* ==============================================
   SCROLLBAR PERSONALIZADO
   ============================================== */
.ayudawp-desplegable-content::-webkit-scrollbar {
    width: 6px;
}

.ayudawp-desplegable-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.ayudawp-desplegable-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.ayudawp-desplegable-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ==============================================
   RESPONSIVE - TABLETS
   ============================================== */
@media screen and (max-width: 1024px) {
    .ayudawp-desplegables-wrapper {
        gap: 12px;
    }

    .ayudawp-desplegable {
        flex: 1 1 calc(50% - 6px);
        min-width: 200px;
    }
}

/* ==============================================
   RESPONSIVE - MOVILES
   ============================================== */
@media screen and (max-width: 768px) {
    .ayudawp-desplegables-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .ayudawp-desplegable {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .ayudawp-desplegable-toggle {
        padding: 14px 16px;
    }

    /* En moviles la caja es relativa, no absoluta */
    .ayudawp-desplegable-content {
        position: relative;
        top: auto;
        margin-top: 0;
        border-top: none;
        border-radius: 0 0 4px 4px;
        box-shadow: none;
        max-height: 50vh; /* Altura en moviles */
    }

    .ayudawp-desplegable-toggle[aria-expanded="true"] {
        border-radius: 4px 4px 0 0;
        border-bottom-color: transparent;
    }
}

/* ==============================================
   RESPONSIVE - MOVILES PEQUENOS
   ============================================== */
@media screen and (max-width: 480px) {
    .ayudawp-desplegable-toggle {
        padding: 12px 14px;
        font-size: 0.95em;
    }

    .ayudawp-desplegable-list li a {
        padding: 6px 14px;
    }

    .ayudawp-desplegable-content {
        max-height: 40vh; /* Altura en moviles pequenos */
    }
}

/* ==============================================
   ACCESIBILIDAD - Preferencias de movimiento reducido
   ============================================== */
@media (prefers-reduced-motion: reduce) {
    .ayudawp-desplegable-toggle,
    .ayudawp-desplegable-icon,
    .ayudawp-desplegable-list li a {
        transition: none;
    }
}