/* ============================================================
   RESPONSIVE MENU - Clean Configuration
   Menu responsive con hamburguesa para móvil
   ============================================================ */

/* Variables de diseño */
:root {
    --cms-menu-bg-mobile: #fff;
    --cms-menu-bg-desktop: transparent;
    --cms-menu-text-color: #333;
    --cms-menu-link-hover-bg: #f0f0f0;
    --cms-menu-link-hover-color: #000;
    --cms-submenu-bg: #fafafa;
    --cms-submenu-border-left: 3px solid var(--pico-primary);
    --cms-transition-speed: 0.3s;
}

/* ============================================================
   HEADER CONTAINER
   ============================================================ */

.cms-header {
    background-color: var(--background-component-color);
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 150;
}

.cms-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 12px 0;
}

/* ============================================================
   LOGO
   ============================================================ */

.cms-logo {
    flex-shrink: 0;
}

.cms-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.cms-logo img {
    max-height: 50px;
    width: auto;
}

/* ============================================================
   HAMBURGER BUTTON (Mobile only)
   ============================================================ */

.cms-menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.cms-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #333;
    border-radius: 2px;
    transition: all var(--cms-transition-speed) ease;
}

/* Animación hamburguesa → X */
.cms-menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.cms-menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.cms-menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Ocultar hamburguesa en desktop */
@media screen and (min-width: 1024px) {
    .cms-menu-toggle {
        display: none;
    }
}

/* ============================================================
   MENU NAVIGATION
   ============================================================ */

.cms-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    max-width: 100%;
    position: relative;
}

@media screen and (max-width: 1023px) {
    .cms-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--cms-menu-bg-mobile);
        border-top: 1px solid var(--cms-menu-link-hover-bg);
        max-height: 0;
        overflow: hidden;
        transition: max-height var(--cms-transition-speed) ease;
    }

    .cms-menu-toggle[aria-expanded="true"] ~ .cms-menu {
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        border-bottom: 1px solid var(--cms-menu-link-hover-bg);
        padding-bottom: 10px;
    }
}

/* ============================================================
   MENU LIST & ITEMS
   ============================================================ */

.cms-menu-list {
    list-style: none;
    margin: 0 !important;
    padding: 0;
    display: flex;
    flex-direction: row;
    gap: 0;
}

@media screen and (max-width: 1023px) {
    .cms-menu-list {
        width: 100%;
        flex-direction: column;
    }

    .cms-menu-list > .cms-menu-item {
        width: 100%;
    }
    .cms-menu-list .cms-menu-link {
        font-size: 16px;
        padding: 16px;
    }
    .cms-menu-list .cms-menu-link:hover {
        color: var(--pico-primary);
    }


}

.cms-menu-item {
    position: relative;
    display: flex;
    align-items: stretch;
    font-size: 14px;
}
.cms-menu-item > .cms-menu-link {
    display: flex;
    align-items: center;
}
.cms-menu-item--has-children {
    align-items: stretch;
    flex-wrap: wrap;
}

.cms-submenu-toggle {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media screen and (max-width: 1023px) {
    .cms-menu-item {
        width: 100%;
        flex-direction: row;
        border-bottom: 1px solid #eee;
    }

    .cms-menu-item:last-child {
        border-bottom: none;
    }
}

/* ============================================================
   MENU LINKS
   ============================================================ */

.cms-menu-link {
    display: block;
    padding: 6px 15px;
    text-decoration: none;
    color: var(--pico-h1-color);
    font-weight: 500;
    transition: all var(--cms-transition-speed) ease;
    white-space: nowrap;
    flex: 1;
}

@media screen and (max-width: 1023px) {
    .cms-menu-link {
        width: 100%;
        padding: 12px 16px;
        font-weight: 400;
    }
}

/* Hover en desktop */
@media screen and (min-width: 1024px) {
    .cms-menu-link:hover {
        /*background-color: var(--cms-menu-link-hover-bg);
        color: var(--cms-menu-link-hover-color);
        border-radius: 4px;*/
        color: var(--pico-primary);
    }
}

/* ============================================================
   SUBMENU TOGGLE BUTTON
   ============================================================ */

.cms-submenu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--cms-menu-text-color);
    font-size: 1.2em;
    transition: transform var(--cms-transition-speed) ease;
    align-self: center;
}

@media screen and (max-width: 1023px) {
    .cms-menu-item--has-children .cms-submenu-toggle {
        display: block;
        margin-left: auto;
    }
}

/* Rotación cuando está abierto */
.cms-submenu-toggle[aria-expanded="true"] {
    transform: rotate(180deg);
}

/* ============================================================
   SUBMENU (Nested list)
   ============================================================ */

.cms-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    position: absolute;
    top: 170%;
    left: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    z-index: 200;
}

/* Desktop: mostrar en hover */
@media screen and (min-width: 1024px) {
    .cms-menu-item--has-children:hover .cms-submenu {
        display: flex;
        flex-direction: column;
    }
}

/* Mobile: mostrar cuando está abierto */
@media screen and (max-width: 1023px) {
    .cms-submenu {
        position: static;
        background-color: var(--cms-submenu-bg);
        border: none;
        border-left: var(--cms-submenu-border-left);
        box-shadow: none;
        border-radius: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height var(--cms-transition-speed) ease;
        display: flex;
        flex-direction: column;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .cms-menu-item--has-children.open .cms-submenu {
        max-height: 1000px;
        padding: 8px 0;
    }

    .cms-menu-item--has-children .cms-menu-link {
        width: 90%;
    }

    .cms-submenu .cms-menu-item {
        width: 100%;
        border-bottom: 1px solid #ddd;
    }

    .cms-submenu .cms-menu-item:last-child {
        border-bottom: none;
    }
}

/* Submenu items */
.cms-submenu .cms-menu-link {
    padding-left: 32px;
    font-size: 0.95em;
}

@media screen and (max-width: 1023px) {
    .cms-submenu .cms-menu-link {
        padding-left: 32px;
    }
}

@media screen and (min-width: 1024px) {
    .cms-submenu .cms-menu-item {
        padding: 10px !important;
        width: 100%;
    }
    .cms-submenu .cms-menu-link {
        padding: 8px 16px;
    }

    .cms-submenu .cms-menu-link:hover {
        background-color: #f5f5f5;
    }
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */

/* En pantallas pequeñas */
@media screen and (max-width: 768px) {
    .cms-header-container {
        gap: 10px;
        padding: 10px;
    }

    .cms-logo img {
        max-height: 45px;
    }

    .cms-menu-link {
        padding: 10px 14px;
        font-size: 0.95em;
    }

    .cms-submenu {
        min-width: 180px;
    }

    .cms-submenu .cms-menu-link {
        padding-left: 28px;
    }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

.cms-menu-link:focus,
.cms-submenu-toggle:focus,
.cms-menu-toggle:focus {
    outline: 2px solid var(--pico-primary);
    outline-offset: 2px;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    .cms-header,
    .cms-menu-toggle {
        display: none;
    }
}

/* ============================================================
   ECOMMERCE ELEMENTS (Search, Cart, User)
   ============================================================ */

.cms-menu-divider {
    display: none;
    height: 1px;
    background-color: #ddd;
    margin: 8px 0;
}

@media screen and (max-width: 1023px) {
    .cms-menu-divider {
        display: block;
    }
}

.cms-menu-section {
    display: flex;
    align-items: center;
    padding: 0;
}

@media screen and (max-width: 1023px) {
    .cms-menu-section {
        width: 100%;
        padding: 8px 16px;
        border-bottom: 1px solid #eee;
    }

    .cms-menu-section:last-child {
        border-bottom: none;
    }
}

/* ============================================================
   SEARCH FORM
   ============================================================ */

.cms-search-form {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.cms-search-form input {
    padding: 0px 12px;
    height: fit-content;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px !important;
    min-width: 150px;
    margin-bottom: 0;
}
.cms-search-form button {
    margin-bottom: 0;
}

@media screen and (max-width: 1023px) {
    .cms-search-form input {
        flex: 1;
        min-width: auto;
    }
}

.cms-search-form input:focus {
    outline: none;
    border-color: var(--pico-primary);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.cms-search-form button {
    background: var(--pico-primary);
    color: white;
    border: none;
    padding: 0px;
    font-size: 14px;
    height: 40px;
    width: 40px;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity var(--cms-transition-speed) ease;
}

.cms-search-form button:hover {
    opacity: 0.7;
}

/* ============================================================
   CART BUTTON
   ============================================================ */

.cms-menu-cart {
    padding: 0;
}

.cms-cart-btn {
    background: none;
    border: none;
    color: #333;
    font-size: .9em;
    cursor: pointer;
    padding: 8px;
    position: relative;
    transition: all var(--cms-transition-speed) ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

@media screen and (max-width: 1023px) {
    .cms-cart-btn {
        font-size: 20px;
    }
    .cms-menu-cart {
        padding: 10px;
    }
}

.cms-cart-btn:hover {
    color: var(--pico-primary);
}

.cms-cart-btn span {
    position: absolute;
    top: -5px;
    right: 0;
    background-color: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-weight: bold;
}

/* ============================================================
   USER LOGIN SECTION
   ============================================================ */

.cms-menu-user {
    padding: 0;
}

@media screen and (min-width: 1024px) {
    .cms-menu-user {
        padding: 0 12px;
    }
}

.cms-user-dropdown {
    cursor: pointer;
}

.cms-user-dropdown summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
    transition: all var(--cms-transition-speed) ease;
}

@media screen and (max-width: 1023px) {
    .cms-user-dropdown summary {
        width: 100%;
    }
    .cms-menu-user {
        padding: 6px 12px;
    }
}

.cms-user-dropdown summary:hover {
    color: var(--pico-primary);
}

.cms-user-dropdown summary::marker {
    content: '';
}

.cms-user-dropdown summary::-webkit-details-marker {
    display: none;
}

.cms-user-dropdown ul {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: 180px;
    z-index: 200;
}

@media screen and (max-width: 1023px) {
    .cms-user-dropdown ul {
        position: static;
        border: none;
        box-shadow: none;
        background-color: #fafafa;
        border-left: 3px solid var(--pico-primary);
        border-radius: 0;
        margin: 8px 0 0 -16px;
        padding: 0;
        width: 100%;
    }

    .cms-user-dropdown {
        width: 100%;
    }
}

.cms-user-dropdown ul li {
    border-bottom: 1px solid #eee;
}

.cms-user-dropdown ul li:last-child {
    border-bottom: none;
}

.cms-user-dropdown ul li a,
.cms-user-dropdown ul li input[type="submit"] {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: #333;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all var(--cms-transition-speed) ease;
}

.cms-user-dropdown ul li a:hover,
.cms-user-dropdown ul li input[type="submit"]:hover {
    background-color: #f5f5f5;
    color: var(--pico-primary);
}

/* ============================================================
   LOGIN BUTTON (when not logged in)
   ============================================================ */

.cms-login-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background-color: var(--pico-primary);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: all var(--cms-transition-speed) ease;
    white-space: nowrap;
    font-size: 15px
}

.cms-menu-user details {
    margin-bottom: 5px;
}
.cms-menu-user details ul {
    padding: 0;
    flex-direction: column;
}
.cms-menu-user details ul li {
    padding: 0;
    width: 100%;
}
.cms-menu-user details[open] > summary{
    margin-bottom: 0;
}

.cms-menu-user ul li a {
    margin: 0 !important;
    font-size: 14px;
}
.cms-menu-user ul li input {
    width: 100%;
    font-size: 14px !important;
    padding: 10px 16px !important;
}


@media screen and (max-width: 1023px) {
    .cms-login-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 0;
        background: none;
        color: #333;
        border-radius: 0;
    }
}

.cms-login-btn:hover {
    opacity: 0.7;
}

@media screen and (max-width: 1023px) {
    .cms-login-btn:hover {
        color: var(--pico-primary);
    }
}
