/* ===== Mega Menu CSS — Mallorquinaria branding ===== */
/* Brand colors:
   - Primary: #22b14c
   - Text: #000000
   - White: #ffffff
   Font (menu/nav): 'Barlow', Helvetica, Arial, sans-serif
*/

.mm-wrap {
    position: relative;
    display: inline-block;
    font-family: 'Barlow', Helvetica, Arial, sans-serif;
}

/* ===== Trigger button ===== */
.mm-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 0;
    padding: 0.5rem 0.75rem;
    color: #000000;
    font-weight: 700;
    font-size: 18px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 0;
    transition: color 0.15s ease;
    font-family: inherit;
    /* Evita la espera del zoom de doble toque en móviles */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mm-toggle:hover {
    color: #22b14c;
}

.mm-toggle .mm-icon {
    width: 1.25rem;
    height: 1.25rem;
}

.mm-toggle .mm-chevron {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s ease;
}

.mm-wrap.is-open .mm-toggle,
.mm-toggle[aria-expanded="true"] {
    color: #22b14c;
}

.mm-wrap.is-open .mm-toggle .mm-chevron {
    transform: rotate(180deg);
}

/* ===== Dropdown panel ===== */
.mm-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0;
    width: 90vw;
    max-width: 72rem;
    background: #ffffff;
    border: 0;
    border-top: 3px solid #22b14c;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 50;
    padding: 1.5rem;
    font-family: 'Barlow', Helvetica, Arial, sans-serif;
}

.mm-wrap.is-open .mm-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mm-inner {
    display: flex;
    width: 100%;
    min-height: 400px;
    max-height: 500px;
    gap: 0;
}

/* ===== Left column: categories ===== */
.mm-cats {
    border-right: 1px solid #e5e7eb;
    width: 18rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.mm-heading {
    font-size: 1.125rem;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
    padding: 0 1rem 0.75rem 1rem;
    border-bottom: 2px solid #22b14c;
}

.mm-cats-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.mm-cat-item {
    cursor: pointer;
    border-left: 4px solid transparent;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    color: #000000;
}

.mm-cat-item:hover {
    background-color: rgba(34, 177, 76, 0.06);
}

.mm-cat-item.is-active {
    background-color: rgba(34, 177, 76, 0.1);
    border-left-color: #22b14c;
}

.mm-cat-item.is-active .mm-cat-name {
    color: #22b14c;
}

.mm-cat-info {
    flex: 1;
    min-width: 0;
    overflow: visible;
}

.mm-cat-name {
    font-weight: 600;
    color: #000000;
    font-size: 0.95rem;
    line-height: 1.25;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
}

.mm-cat-count {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.mm-cat-arrow {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    color: #9ca3af;
}

.mm-cat-item.is-active .mm-cat-arrow {
    color: #22b14c;
}

.mm-cat-item-nolink {
    cursor: default;
}

/* ===== Right column: subcategories ===== */
.mm-subs {
    flex: 1;
    padding: 0 1.25rem;
    overflow-y: auto;
    scroll-behavior: smooth;
    min-width: 0;
}

.mm-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: #6b7280;
}

.mm-empty-icon {
    width: 4rem;
    height: 4rem;
    color: #d1d5db;
    margin: 0 auto 1rem;
    display: block;
}

.mm-sub-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #22b14c;
}

.mm-sub-header img {
    width: 3rem;
    height: 3rem;
    object-fit: contain;
    border-radius: 0;
}

/* La imagen de la categoría principal ya no se muestra en la cabecera */
.mm-sub-header:not(:has(img)) {
    gap: 0;
}

.mm-sub-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.mm-sub-meta {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.mm-sub-empty-msg {
    text-align: center;
    padding: 3rem 1rem;
}

.mm-sub-empty-msg h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 0.5rem;
}

.mm-sub-empty-msg p {
    color: #6b7280;
    margin: 0 0 1rem;
}

.mm-sub-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 480px) {
    .mm-sub-grid { grid-template-columns: minmax(0, 1fr); }
}

.mm-sub-card {
    display: flex;
    align-items: stretch;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mm-sub-card:hover {
    border-color: #22b14c;
    box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.08);
}

.mm-sub-card-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    text-decoration: none;
    color: #000000;
    min-width: 0;
    transition: background-color 0.15s ease;
}

.mm-sub-card-link:hover {
    background-color: rgba(34, 177, 76, 0.04);
}

.mm-sub-card-thumb {
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: 0;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mm-sub-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Icono de respaldo en las tarjetas de subcategorías (sin imagen) */
.mm-thumb-placeholder {
    width: 1.25rem;
    height: 1.25rem;
    color: #9ca3af;
}

.mm-sub-card-body {
    min-width: 0;
    flex: 1;
}

.mm-sub-card-name {
    font-weight: 700;
    color: #22b14c;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    transition: color 0.15s ease;
}

.mm-sub-card-nolink {
    /* No visual distinction for container categories in the right panel */
}

.mm-sub-card-link-disabled {
    cursor: default;
}

.mm-sub-card-link-disabled:hover {
    background-color: transparent;
}

.mm-sub-card-link:hover .mm-sub-card-name {
    color: #000000;
}

.mm-sub-card-count {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0.125rem 0 0;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.mm-sub-card-toggle {
    flex-shrink: 0;
    width: 2.75rem;
    border: 0;
    border-left: 1px solid #e5e7eb;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-family: inherit;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mm-sub-card-toggle:hover {
    background-color: #f0fdf4;
    color: #22b14c;
}

.mm-sub-card-toggle:focus-visible {
    outline: 2px solid #22b14c;
    outline-offset: -2px;
}

.mm-sub-card-toggle svg {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s ease;
}

.mm-sub-card-toggle[aria-expanded="true"] {
    background-color: #22b14c;
    color: #ffffff;
    border-left-color: #22b14c;
}

.mm-sub-card-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* ===== Sub-sub-categorías (nivel 3) ===== */
.mm-sub-card-wrap {
    display: flex;
    flex-direction: column;
}

.mm-sub-card-children {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-top: 0;
    background: #fafafa;
    display: none;
}

.mm-sub-card-children li {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #e5e7eb;
}

.mm-sub-card-children li::marker {
    content: '';
}

.mm-sub-card-children.is-open {
    display: block;
}

.mm-sub-card-children li:last-child {
    border-bottom: 0;
}

.mm-sub-card-children a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    color: #4b5563;
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.mm-sub-card-children a::before {
    content: none;
}

.mm-sub-card-children a:hover {
    color: #000000;
    background-color: rgba(34, 177, 76, 0.05);
}

.mm-sub-child-thumb {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    border-radius: 0;
    background: #f3f4f6;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mm-sub-child-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mm-sub-child-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Filtro de subcategorías ===== */
.mm-filter {
    position: relative;
    margin-bottom: 1rem;
}

.mm-filter-input {
    width: 100%;
    padding: 0.625rem 2.25rem 0.625rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    background: #ffffff;
    font-family: inherit;
    font-size: 0.875rem;
    color: #000000;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mm-filter-input:focus {
    outline: 0;
    border-color: #22b14c;
    box-shadow: 0 0 0 1px #22b14c;
}

.mm-filter-input::placeholder {
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

.mm-filter-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.5rem;
    height: 1.5rem;
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.mm-filter-clear:hover {
    color: #000000;
    background-color: #f3f4f6;
}

.mm-filter-empty {
    padding: 2rem 1rem;
}

/* ===== Footer link (CTA inside panel) ===== */
.mm-footer-link {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.mm-footer-link a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #22b14c;
    color: #ffffff;
    font-weight: 700;
    font-family: 'Barlow', Helvetica, Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.875rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mm-footer-link a:hover {
    background: #000000;
    color: #ffffff;
}

.mm-footer-link svg {
    width: 1rem;
    height: 1rem;
}

/* ===== Subcategory "no subs" CTA ===== */
.mm-sub-empty-msg a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #22b14c;
    color: #ffffff;
    font-weight: 700;
    font-family: 'Barlow', Helvetica, Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.875rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mm-sub-empty-msg a:hover {
    background: #000000;
    color: #ffffff;
}

/* ===== Scrollbars ===== */
.mm-cats-list::-webkit-scrollbar,
.mm-subs::-webkit-scrollbar {
    width: 6px;
}

.mm-cats-list::-webkit-scrollbar-track,
.mm-subs::-webkit-scrollbar-track {
    background: transparent;
}

.mm-cats-list::-webkit-scrollbar-thumb,
.mm-subs::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.mm-cats-list::-webkit-scrollbar-thumb:hover,
.mm-subs::-webkit-scrollbar-thumb:hover {
    background: #22b14c;
}

/* ===== Botón de cierre (solo móvil) ===== */
.mm-close {
    display: none;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    color: #000000;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.mm-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

.mm-close:hover,
.mm-close:focus-visible {
    color: #ffffff;
    background: #22b14c;
    border-color: #22b14c;
    outline: none;
}

/* ===== Botón "volver" (solo en táctil) ===== */
.mm-sub-back {
    display: none;
    width: 100%;
    align-items: center;
    gap: 0.375rem;
    background: transparent;
    border: 0;
    border-bottom: 2px solid #22b14c;
    padding: 0.5rem 0 0.625rem 0;
    margin-bottom: 0.75rem;
    font-family: 'Barlow', Helvetica, Arial, sans-serif;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #22b14c;
    cursor: pointer;
    transition: color 0.15s ease;
}

.mm-sub-back svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.mm-sub-back:hover {
    color: #000000;
}

/* ===== Modo táctil (la clase la pone el JS, igual que usa el JS) =====
   Se aplica por clase y no por media query para que estilos y
   comportamiento nunca puedan quedar desincronizados (tabletas,
   móviles apaisados, etc.). */
.mm-wrap.mm-touch .mm-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: none;
    height: 100vh;
    max-height: 100vh;
    margin-top: 0;
    border-top: 0;
    border-radius: 0;
    padding: 1rem;
    /* Deja libre la franja que ocupa la cabecera del sitio, para que el
       botón de cerrar y el buscador no queden tapados */
    padding-top: calc(var(--mm-header-h, 0px) + 1rem);
}

.mm-wrap.mm-touch .mm-inner {
    flex-direction: column;
    max-height: calc(100vh - var(--mm-header-h, 0px) - 2rem);
    min-height: 0;
}

.mm-wrap.mm-touch .mm-cats {
    width: 100%;
    border-right: 0;
    border-bottom: 2px solid #22b14c;
    max-height: 40vh;
}

.mm-wrap.mm-touch .mm-subs {
    width: 100%;
    padding: 0;
}

.mm-wrap.mm-touch .mm-sub-grid {
    grid-template-columns: minmax(0, 1fr);
}

/* Botón de cierre siempre visible en táctil, por debajo de la cabecera */
.mm-wrap.mm-touch .mm-close {
    display: inline-flex;
    top: calc(var(--mm-header-h, 0px) + 0.75rem);
}

/* El encabezado no debe quedar debajo del botón de cierre */
.mm-wrap.mm-touch .mm-heading {
    padding-right: 3.25rem;
}

/* Botón "volver a las categorías" */
.mm-wrap.mm-touch .mm-sub-back {
    display: inline-flex;
}

/* Al entrar a una categoría, la lista de principales se oculta
   y las subcategorías ocupan toda la pantalla */
.mm-wrap.mm-drilldown .mm-cats {
    display: none;
}

.mm-wrap.mm-drilldown .mm-subs {
    flex: 1;
    min-height: 0;
}
