/* ============================================
   Widget de Categorías Dinámico
   Archivo: assets/categorias.css
   Versión: 1.1.0 — Acordeón
   ============================================ */

/* ── Reset base del widget ─────────────────── */
.mwc-categorias-widget,
.mwc-shortcode {
    font-family: inherit;
}

/* ── Lista principal ───────────────────────── */
.mwc-lista-categorias {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ── Cada ítem de categoría ────────────────── */
.mwc-lista-categorias .mwc-item {
    position: relative;
    border-bottom: 1px solid #f0f0f0;
}

.mwc-lista-categorias .mwc-item:last-child {
    border-bottom: none;
}

/* ── Fila: link + botón toggle ─────────────── */
.mwc-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Enlace de categoría ───────────────────── */
.mwc-lista-categorias .mwc-item > .mwc-item-row > .mwc-cat-link {
    display: flex;
    align-items: center;
    flex: 1;                   /* Ocupa todo el ancho disponible */
    gap: 8px;
    padding: 10px 14px;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.mwc-lista-categorias .mwc-item > .mwc-item-row > .mwc-cat-link:hover {
    color: #0073aa;
    padding-left: 20px;
}

/* Indicador de categoría activa */
.mwc-lista-categorias .mwc-item.current-cat > .mwc-item-row > .mwc-cat-link,
.mwc-lista-categorias .mwc-item.current-cat-ancestor > .mwc-item-row > .mwc-cat-link {
    color: #0073aa;
    font-weight: 700;
    border-left: 3px solid #0073aa;
    padding-left: 11px;
}

/* ── Contador de artículos ─────────────────── */
.mwc-count {
    font-size: 0.78rem;
    color: #999;
    background: #f5f5f5;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 400;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.mwc-cat-link:hover .mwc-count {
    background: #e8f4fc;
    color: #0073aa;
}

/* ── Botón toggle (flecha) ─────────────────── */
.mwc-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    margin-right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    outline: none;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.mwc-toggle:hover {
    background-color: #f0f0f0;
}

/* Icono de flecha con CSS puro */
.mwc-toggle-icon {
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid #999;
    border-bottom: 2px solid #999;
    transform: rotate(-45deg);          /* Apunta a la derecha = cerrado */
    transition: transform 0.25s ease, border-color 0.2s ease;
    margin-top: -2px;                   /* Ajuste visual centrado */
}

/* Flecha girada hacia abajo cuando está abierto */
.mwc-item.open > .mwc-item-row .mwc-toggle-icon {
    transform: rotate(45deg);           /* Apunta hacia abajo = abierto */
    margin-top: 2px;
}

.mwc-toggle:hover .mwc-toggle-icon {
    border-color: #0073aa;
}

/* ── Subcategorías ─────────────────────────── */
.mwc-subcategorias {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s ease;
}

/* Abrir cuando el padre tiene clase .open */
.mwc-item.open > .mwc-subcategorias {
    max-height: 1000px; /* Suficiente para cualquier cantidad de subcategorías */
}

/* También mantener abierto si es la categoría actual o ancestro */
.mwc-item.current-cat > .mwc-subcategorias,
.mwc-item.current-cat-ancestor > .mwc-subcategorias {
    max-height: 1000px;
}

.mwc-subcategorias .mwc-subitem {
    border-bottom: 1px solid #ebebeb;
}

.mwc-subcategorias .mwc-subitem:last-child {
    border-bottom: none;
}

.mwc-subcategorias .mwc-subitem a {
    display: block;
    padding: 8px 14px 8px 28px;
    color: #555;
    text-decoration: none;
    font-size: 0.88rem;
    transition: color 0.2s ease, padding-left 0.2s ease;
    position: relative;
}

/* Flecha indicadora de subcategoría */
.mwc-subcategorias .mwc-subitem a::before {
    content: "›";
    position: absolute;
    left: 16px;
    color: #bbb;
    font-size: 1rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.mwc-subcategorias .mwc-subitem a:hover {
    color: #0073aa;
    padding-left: 32px;
}

.mwc-subcategorias .mwc-subitem a:hover::before {
    color: #0073aa;
}

/* Subcategoría activa */
.mwc-subcategorias .mwc-subitem.current-cat a {
    color: #0073aa;
    font-weight: 600;
}

.mwc-subcategorias .mwc-subitem.current-cat a::before {
    color: #0073aa;
}

/* ── Mensaje sin categorías ────────────────── */
.mwc-sin-categorias {
    color: #999;
    font-size: 0.9rem;
    padding: 10px 0;
    margin: 0;
    font-style: italic;
}

/* ── Responsivo ────────────────────────────── */
@media (max-width: 768px) {
    .mwc-lista-categorias .mwc-item > .mwc-item-row > .mwc-cat-link {
        padding: 12px 14px;
        font-size: 1rem;
    }

    .mwc-toggle {
        width: 44px;
        height: 44px;
    }
}
