/**
 * Refinamientos de interacción del Header global.
 * Se carga después de global-header.css para aislar estos ajustes del tema activo.
 */

#cmds-global-header {
    --cm-accent-soft: rgba(255, 151, 0, 0.13);
    --cm-border-strong: rgba(255, 255, 255, 0.22);
    --cm-focus-ring: 0 0 0 3px rgba(255, 151, 0, 0.22);
}

#cmds-global-header button,
#cmds-global-header input,
#cmds-global-header a {
    font-family: inherit;
}

#cmds-global-header button {
    text-transform: none;
    letter-spacing: normal;
    box-shadow: none;
}

/* Buscador principal y CTA. */
#cmds-global-header .cmds-header-search {
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

#cmds-global-header .cmds-header-search:hover {
    border-color: #dedede;
}

#cmds-global-header .cmds-header-search:focus-within {
    border-color: var(--cm-accent);
    box-shadow: var(--cm-focus-ring);
}

#cmds-global-header .cmds-header-search__icon {
    transition: color 0.18s ease;
}

#cmds-global-header .cmds-header-search:focus-within .cmds-header-search__icon {
    color: #a45d00;
}

#cmds-global-header .cmds-header-search button[type="submit"] {
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    background: var(--cm-accent) !important;
    color: #1b1b1b !important;
    box-shadow: none !important;
    transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

#cmds-global-header .cmds-header-search button[type="submit"]:hover {
    border-color: transparent !important;
    background: #ffad2f !important;
    color: #151515 !important;
    box-shadow: 0 7px 16px rgba(255, 151, 0, 0.24) !important;
    transform: translateY(-1px);
}

#cmds-global-header .cmds-header-search button[type="submit"]:active {
    background: #e98500 !important;
    box-shadow: none !important;
    transform: translateY(0);
}

#cmds-global-header .cmds-header-search button[type="submit"]:focus-visible {
    outline: 2px solid #1b1b1b !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(255, 151, 0, 0.3) !important;
}

/* Live Search: jerarquía, legibilidad y estados interactivos. */
#cmds-global-header .cmds-header-search-results {
    top: calc(100% + 10px);
    max-height: min(580px, 72vh);
    overscroll-behavior: contain;
    border-color: #e4e4e4;
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.2);
    scrollbar-width: thin;
}

#cmds-global-header .cmds-search-section-title {
    color: #7b7b7b;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.11em;
}

#cmds-global-header .cmds-search-category-list a {
    position: relative;
    min-height: 32px;
    padding: 7px 11px 7px 25px;
    border: 1px solid #ececec !important;
    background: #f7f7f7 !important;
    color: #3b3b3b !important;
    box-shadow: none !important;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

#cmds-global-header .cmds-search-category-list a::before {
    content: "";
    position: absolute;
    left: 11px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cm-accent);
}

#cmds-global-header .cmds-search-category-list a:hover,
#cmds-global-header .cmds-search-category-list a:focus-visible {
    border-color: #ffd49a !important;
    background: #fff5e7 !important;
    color: #8d5000 !important;
    outline: none;
    transform: translateY(-1px);
}

#cmds-global-header .cmds-search-category-list a:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 151, 0, 0.24) !important;
}

#cmds-global-header .cmds-search-product {
    grid-template-columns: 62px minmax(0, 1fr) minmax(105px, auto);
    min-height: 80px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: #fff !important;
    color: #222 !important;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

#cmds-global-header .cmds-search-product + .cmds-search-product {
    margin-top: 2px;
}

#cmds-global-header .cmds-search-product:hover,
#cmds-global-header .cmds-search-product:focus-visible {
    border-color: #ffe0b3;
    background: #fff9f1 !important;
    color: #222 !important;
    box-shadow: 0 7px 18px rgba(31, 31, 31, 0.07);
    outline: none;
    transform: translateY(-1px);
}

#cmds-global-header .cmds-search-product img,
#cmds-global-header .cmds-search-product__image-placeholder {
    display: block;
    width: 62px;
    height: 62px;
    border: 1px solid #efefef;
    border-radius: 10px;
    object-fit: contain;
    background: #f5f5f5;
}

#cmds-global-header .cmds-search-product__copy strong {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.3;
    white-space: normal;
}

#cmds-global-header .cmds-search-product__copy small {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    margin-top: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #f2f2f2;
    color: #777;
    font-size: 10px;
    line-height: 1.2;
}

#cmds-global-header .cmds-search-product__price {
    justify-self: end;
    max-width: 220px;
    padding-left: 10px;
    color: #d77900;
    font-size: 12.5px;
    font-weight: 850;
    line-height: 1.35;
    text-align: right;
    white-space: normal;
}

#cmds-global-header .cmds-search-view-all {
    min-height: 42px;
    border-radius: 0 0 10px 10px;
    color: #a65c00 !important;
    transition: background 0.16s ease, color 0.16s ease;
}

#cmds-global-header .cmds-search-view-all:hover,
#cmds-global-header .cmds-search-view-all:focus-visible {
    background: #fff4e4 !important;
    color: #774100 !important;
    outline: none;
}

/* Cuenta y carrito: hover sutil, sin bloques naranjas invasivos. */
#cmds-global-header .cmds-header-account,
#cmds-global-header .cmds-header-cart-button {
    min-height: 50px;
    padding: 6px 10px;
    border: 1px solid transparent !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: #fff !important;
    box-shadow: none !important;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

#cmds-global-header .cmds-header-account:hover,
#cmds-global-header .cmds-header-cart-button:hover {
    border-color: var(--cm-border-strong) !important;
    background: rgba(255, 255, 255, 0.065) !important;
    color: #fff !important;
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.12) !important;
    transform: translateY(-1px);
}

#cmds-global-header .cmds-header-cart-button[aria-expanded="true"] {
    border-color: rgba(255, 151, 0, 0.55) !important;
    background: var(--cm-accent-soft) !important;
    color: #fff !important;
    box-shadow: inset 0 0 0 1px rgba(255, 151, 0, 0.08) !important;
}

#cmds-global-header .cmds-header-account:active,
#cmds-global-header .cmds-header-cart-button:active {
    transform: translateY(0);
}

#cmds-global-header .cmds-header-account:focus-visible,
#cmds-global-header .cmds-header-cart-button:focus-visible {
    border-color: var(--cm-accent) !important;
    outline: none !important;
    box-shadow: var(--cm-focus-ring) !important;
}

#cmds-global-header .cmds-header-account:hover .cmds-header-action-icon,
#cmds-global-header .cmds-header-cart-button:hover .cmds-header-action-icon,
#cmds-global-header .cmds-header-cart-button[aria-expanded="true"] .cmds-header-action-icon {
    color: #ffc266;
}

#cmds-global-header .cmds-header-cart-badge {
    border: 2px solid #1c1c1c;
    font-size: 9px;
    font-weight: 850;
}

#cmds-global-header .cmds-header-cart-panel {
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22);
}

#cmds-global-header .cmds-header-cart-item {
    border: 1px solid transparent;
    color: #2b2b2b !important;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

#cmds-global-header .cmds-header-cart-item:hover,
#cmds-global-header .cmds-header-cart-item:focus-visible {
    border-color: #ececec;
    background: #f8f8f8 !important;
    color: #1f1f1f !important;
    outline: none;
    transform: translateX(2px);
}

#cmds-global-header .cmds-header-cart-item img {
    object-fit: contain;
    border: 1px solid #ededed;
    background: #f7f7f7;
}

#cmds-global-header .cmds-header-cart-actions a {
    min-height: 40px;
    box-shadow: none !important;
    transition: background 0.17s ease, border-color 0.17s ease, color 0.17s ease, box-shadow 0.17s ease, transform 0.17s ease;
}

#cmds-global-header .cmds-header-cart-secondary {
    border: 1px solid #d9d9d9 !important;
    background: #fff !important;
    color: #333 !important;
}

#cmds-global-header .cmds-header-cart-secondary:hover,
#cmds-global-header .cmds-header-cart-secondary:focus-visible {
    border-color: #bdbdbd !important;
    background: #f3f3f3 !important;
    color: #181818 !important;
    outline: none;
    transform: translateY(-1px);
}

#cmds-global-header .cmds-header-cart-primary {
    border: 1px solid var(--cm-accent) !important;
    background: var(--cm-accent) !important;
    color: #191919 !important;
}

#cmds-global-header .cmds-header-cart-primary:hover,
#cmds-global-header .cmds-header-cart-primary:focus-visible {
    border-color: #ffad2f !important;
    background: #ffad2f !important;
    color: #151515 !important;
    outline: none;
    box-shadow: 0 7px 15px rgba(255, 151, 0, 0.22) !important;
    transform: translateY(-1px);
}

/* Categorías: mega menú compacto con tarjetas y viñetas. */
#cmds-global-header .cmds-header-categories__toggle {
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    background: transparent !important;
    color: #fff !important;
    box-shadow: none !important;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

#cmds-global-header .cmds-header-categories__toggle:hover {
    border-color: rgba(255, 255, 255, 0.46) !important;
    background: rgba(255, 255, 255, 0.065) !important;
    color: #fff !important;
    box-shadow: none !important;
    transform: translateY(-1px);
}

#cmds-global-header .cmds-header-categories.is-open .cmds-header-categories__toggle,
#cmds-global-header .cmds-header-categories__toggle[aria-expanded="true"] {
    border-color: rgba(255, 151, 0, 0.75) !important;
    background: var(--cm-accent-soft) !important;
    color: #fff !important;
    box-shadow: inset 0 0 0 1px rgba(255, 151, 0, 0.08) !important;
    transform: none;
}

#cmds-global-header .cmds-header-categories__toggle:focus-visible {
    border-color: var(--cm-accent) !important;
    outline: none !important;
    box-shadow: var(--cm-focus-ring) !important;
}

#cmds-global-header .cmds-header-categories__panel {
    width: min(1040px, calc(100vw - 48px));
    padding: 16px;
    background: #f7f7f8;
    border-color: #e4e4e4;
    border-radius: 16px;
    box-shadow: 0 24px 65px rgba(0, 0, 0, 0.22);
}

#cmds-global-header .cmds-header-category-grid {
    gap: 10px;
}

#cmds-global-header .cmds-header-category-column {
    min-width: 0;
    padding: 13px;
    border: 1px solid #e8e8e8;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
    transition: border-color 0.17s ease, box-shadow 0.17s ease, transform 0.17s ease;
}

#cmds-global-header .cmds-header-category-column:hover {
    border-color: #f3c785;
    box-shadow: 0 9px 24px rgba(35, 35, 35, 0.08);
    transform: translateY(-2px);
}

#cmds-global-header .cmds-header-category-parent {
    position: relative;
    min-height: 32px;
    margin-bottom: 9px;
    padding: 6px 7px 6px 27px;
    border-radius: 8px;
    color: #202020 !important;
    font-size: 13px;
    font-weight: 850;
    line-height: 1.3;
    transition: background 0.16s ease, color 0.16s ease;
}

#cmds-global-header .cmds-header-category-parent::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 8px;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 151, 0, 0.28);
    border-radius: 3px;
    background: var(--cm-accent);
    transform: translateY(-50%);
}

#cmds-global-header .cmds-header-category-parent:hover,
#cmds-global-header .cmds-header-category-parent:focus-visible {
    background: #fff3e2 !important;
    color: #8b4e00 !important;
    outline: none;
}

#cmds-global-header .cmds-header-category-column li + li {
    margin-top: 2px;
}

#cmds-global-header .cmds-header-category-column li a {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 7px 5px 20px;
    border-radius: 7px;
    color: #676767 !important;
    font-size: 11.5px;
    line-height: 1.3;
    transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

#cmds-global-header .cmds-header-category-column li a::before {
    content: "";
    position: absolute;
    left: 8px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #c9c9c9;
    transition: background 0.15s ease, transform 0.15s ease;
}

#cmds-global-header .cmds-header-category-column li a:hover,
#cmds-global-header .cmds-header-category-column li a:focus-visible {
    background: #f7f7f7 !important;
    color: #9b5800 !important;
    outline: none;
    padding-left: 23px;
}

#cmds-global-header .cmds-header-category-column li a:hover::before,
#cmds-global-header .cmds-header-category-column li a:focus-visible::before {
    background: var(--cm-accent);
    transform: scale(1.3);
}

/* Menú primario: hover de navegación, no botón sólido. */
#cmds-global-header .cmds-header-primary-menu > li > a {
    position: relative;
    border-radius: 9px;
    background: transparent !important;
    color: #efefef !important;
    transition: background 0.17s ease, color 0.17s ease;
}

#cmds-global-header .cmds-header-primary-menu > li > a::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 4px;
    height: 2px;
    border-radius: 999px;
    background: var(--cm-accent);
    opacity: 0;
    transform: scaleX(0.35);
    transition: opacity 0.17s ease, transform 0.17s ease;
}

#cmds-global-header .cmds-header-primary-menu > li > a:hover,
#cmds-global-header .cmds-header-primary-menu > li > a:focus-visible,
#cmds-global-header .cmds-header-primary-menu > li.current-menu-item > a,
#cmds-global-header .cmds-header-primary-menu > li.current-menu-ancestor > a {
    background: rgba(255, 255, 255, 0.065) !important;
    color: #fff !important;
    outline: none;
}

#cmds-global-header .cmds-header-primary-menu > li > a:hover::after,
#cmds-global-header .cmds-header-primary-menu > li > a:focus-visible::after,
#cmds-global-header .cmds-header-primary-menu > li.current-menu-item > a::after,
#cmds-global-header .cmds-header-primary-menu > li.current-menu-ancestor > a::after {
    opacity: 1;
    transform: scaleX(1);
}

#cmds-global-header .cmds-header-primary-menu .sub-menu a {
    background: transparent !important;
    color: #3b3b3b !important;
    transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

#cmds-global-header .cmds-header-primary-menu .sub-menu a:hover,
#cmds-global-header .cmds-header-primary-menu .sub-menu a:focus-visible {
    background: #fff2df !important;
    color: #8d5000 !important;
    outline: none;
    padding-left: 13px;
}

#cmds-global-header .cmds-header-socials a {
    background: transparent !important;
    color: #fff !important;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

#cmds-global-header .cmds-header-socials a:hover,
#cmds-global-header .cmds-header-socials a:focus-visible {
    border-color: var(--cm-accent) !important;
    background: var(--cm-accent) !important;
    color: #191919 !important;
    outline: none;
    transform: translateY(-1px);
}

#cmds-global-header .cmds-header-mobile-toggle {
    background: transparent !important;
    color: #fff !important;
    box-shadow: none !important;
    transition: background 0.17s ease, border-color 0.17s ease, color 0.17s ease;
}

#cmds-global-header .cmds-header-mobile-toggle:hover,
#cmds-global-header .cmds-header-mobile-toggle[aria-expanded="true"] {
    border-color: rgba(255, 151, 0, 0.6) !important;
    background: var(--cm-accent-soft) !important;
    color: #ffc266 !important;
}

#cmds-global-header .cmds-header-mobile-toggle:focus-visible {
    border-color: var(--cm-accent) !important;
    outline: none !important;
    box-shadow: var(--cm-focus-ring) !important;
}

@media (max-width: 1100px) {
    #cmds-global-header .cmds-header-account,
    #cmds-global-header .cmds-header-cart-button {
        padding: 6px;
    }

    #cmds-global-header .cmds-header-category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    #cmds-global-header .cmds-header-categories__panel {
        width: 100%;
        padding: 10px;
        box-shadow: none;
    }

    #cmds-global-header .cmds-header-category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    #cmds-global-header .cmds-header-primary-menu > li > a::after {
        right: auto;
        width: 22px;
    }

    #cmds-global-header .cmds-header-primary-menu .sub-menu a {
        color: #cfcfcf !important;
    }

    #cmds-global-header .cmds-header-primary-menu .sub-menu a:hover,
    #cmds-global-header .cmds-header-primary-menu .sub-menu a:focus-visible {
        background: rgba(255, 255, 255, 0.055) !important;
        color: #fff !important;
    }
}

@media (max-width: 560px) {
    #cmds-global-header .cmds-header-category-grid {
        grid-template-columns: 1fr;
    }

    #cmds-global-header .cmds-header-category-column {
        padding: 11px;
    }
}

@media (max-width: 480px) {
    #cmds-global-header .cmds-search-product {
        grid-template-columns: 54px minmax(0, 1fr);
        min-height: 72px;
    }

    #cmds-global-header .cmds-search-product img,
    #cmds-global-header .cmds-search-product__image-placeholder {
        width: 54px;
        height: 54px;
    }

    #cmds-global-header .cmds-search-product__price {
        grid-column: 2;
        justify-self: start;
        max-width: none;
        padding-left: 0;
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    #cmds-global-header *,
    #cmds-global-header *::before,
    #cmds-global-header *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
    }
}
