.custom-header {
    background: #e8d9bf;
    padding: 16px 0;

    & .container {
        max-width: 1200px;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1.6rem;

        @media (max-width: 1200px) {
            max-width: 90%;
        }
    }
}

/* SEARCH */
.header-search {
    & form {
        display: flex;
        align-items: center;
        position: relative;
    }

    & button {
        background: transparent;
        padding: 0;
        stroke: #3f2c75;
        position: absolute;
        border: 0 !important;
        height: fit-content;
        left: 10px;

        & svg {
            width: 16px;
            height: 16px;
        }

        &:hover {
            background: transparent !important;
        }
    }

    & input {
        border-radius: 18px !important;
        border: 1px solid #e9e9e9 !important;
        background: #fff !important;
        padding: 0 1rem 0 3rem !important;
    }
}

/* LOGO */
.header-logo {
    & img {
        max-height: 100px;
    }
}

/* ACTIONS */
.header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.header-actions .blogLink {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #3f2c75;
    font-weight: 600;
    cursor: pointer;

    &:hover {
        color: #efa61f;
    }
}

/* CATEGORIAS */
.categories-dropdown {
    position: relative;

    &:hover .categories-menu {
        display: grid;
    }
}

.categories-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #3f2c75;
    font-weight: 600;
    cursor: pointer;
}

.categories-menu {
    display: none;
    grid-template-columns: 1fr 1fr;
    position: absolute;
    z-index: 2;
    top: 100%;
    border-radius: 4px;
    right: 0;
    background: #fff;
    padding: 12px;
    list-style: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 500px;
    justify-content: space-between;
    gap: 0.8rem;

    &.open {
        display: grid;
    }

    & li {
        width: 100%;
    }

    & a {
        display: block;
        padding: 6px 8px;
        color: #3f2c75;
        text-decoration: none;
        border-radius: 4px;

        &:hover {
            background: #f5f5f5;
        }
    }
}

.category-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    color: #3f2c75;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;

    &:hover {
        background: #f5f5f5;
    }

    &::after {
        content: '+';
        font-size: 14px;
        transition: transform 0.2s;
    }
}

.has-children {
    &.active .category-toggle::after {
        transform: rotate(45deg);
    }
}

.subcategories {
    display: none;
    list-style: none;
    padding-left: 16px;
    margin-top: 4px;
    margin-bottom: 4px;

    & li {
        margin-bottom: 2px;
    }

    & a {
        font-size: 14px;
        padding: 4px 8px;
    }
}

/* ICON LINK */
.icon-link {
    background-color: transparent;
    position: relative;
}

.cart-count,
.wishlist-count {
    background: #d83764;
    color: #fff;
    font-weight: 700;
    border-radius: 99px;
    position: absolute;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    top: -8px;
    right: -6px;
}

/* MINI CART */
.mini-cart-button {
    background: #efa61f;
    width: 100%;
    display: flex;
    border-radius: 4px;
    padding: 1rem;
    text-align: center;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;

    &:hover {
        background: #3f2c75;
        color: #fff;
    }
}

.mini-cart-container {
    position: relative !important;
}

.mini-cart {
    position: fixed !important;
    top: 0 !important;
    right: -400px !important;
    width: 360px !important;
    height: 100vh !important;
    background: #fff !important;
    z-index: 10000 !important;
    transition: all 0.3s ease !important;
    overflow-y: auto !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1) !important;
    transform: translateX(0) !important;
    visibility: hidden !important;
    opacity: 0 !important;
    border-left: 1px solid #eee !important;

    &.active {
        right: 0 !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    & .woocommerce-mini-cart {
        padding: 20px;
        list-style: none;
        margin: 0;
    }
}

.mini-cart-overlay {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 9999 !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;

    &.active {
        display: block !important;
        opacity: 1 !important;
    }
}

.mini-cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 0 20px;

    & h3 {
        margin: 0;
        color: #3f2c75;
        font-size: 18px;
        font-weight: 600;
    }
}

.mini-cart-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.mini-cart .woocommerce-mini-cart {
    padding: 20px;
    list-style: none;
    margin: 0;
}

.mini-cart-item-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.mini-cart-item-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;

    & img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 4px;
    }
}

.mini-cart-item-details {
    flex: 1;
    min-width: 0;
}

.mini-cart-item-name {
    display: block;
    font-weight: 500;
    color: #3f2c75;
    text-decoration: none;
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 1.3;

    &:hover {
        text-decoration: underline;
    }
}

.mini-cart-item-price {
    display: block;
    color: #666;
    font-size: 13px;
    font-weight: 500;
}

.mini-cart-item-remove {
    flex-shrink: 0;

    & .remove {
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 4px;
        border-radius: 4px;
        transition: background 0.2s;

        &:hover {
            background: #f5f5f5;
        }
    }
}

.mini-cart-item-quantity {
    margin-top: 8px;
    text-align: center;

    & .quantity {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    & input {
        width: 50px;
        text-align: center;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 4px;
    }
}

.mini-cart .woocommerce-mini-cart__total {
    padding: 0 20px 20px;
    margin: 0;
    text-align: left;
    font-weight: 600;
    color: #3f2c75;
}

.mini-cart .woocommerce-mini-cart__buttons {
    padding: 0 20px 20px;
    text-align: center;
}

.mini-cart .woocommerce-mini-cart__buttons .button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 8px;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    text-decoration: none;
    font-weight: 500;
    gap: 8px;
    background: #3f2c75 !important;
    color: white !important;
    border: none !important;
    transition: background 0.2s !important;
}

.mini-cart .woocommerce-mini-cart__buttons .button:hover {
    background: #2c1f56 !important;
    color: white !important;
    text-decoration: none !important;
}

/* Ocultar o subtotal duplicado */
.mini-cart .woocommerce-mini-cart__total .woocommerce-Price-amount {
    display: inline !important;
}

/* Garantir que o botão tenha o ícone correto */
.mini-cart .woocommerce-mini-cart__buttons .button svg {
    width: 16px !important;
    height: 9px !important;
    fill: white !important;
}

.mini-cart .woocommerce-mini-cart__empty-message {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.product_list_widget li {
    display: block !important;
}

/* Prevenir scroll do body quando mini-cart está aberto */
body.mini-cart-open,
body.mobile-menu-open {
    overflow: hidden !important;
}

/* Ocultar mini-cart padrão do WooCommerce */
.woocommerce-mini-cart__empty-message,
.woocommerce.widget_shopping_cart .woocommerce-mini-cart__total,
.woocommerce.widget_shopping_cart .woocommerce-mini-cart__buttons,
.widget_shopping_cart .woocommerce-mini-cart__total,
.widget_shopping_cart .woocommerce-mini-cart__buttons {
    display: none !important;
}

/* Garantir que o mini-cart personalizado seja o único visível */
.mini-cart-container .mini-cart {
    display: block !important;
}

/* MOBILE MENU */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    z-index: 100;
    height: fit-content;
    line-height: normal;
    align-items: center;
    justify-content: center;
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background: #fff;
    z-index: 10001;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);

    &.active {
        left: 0;
    }
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;

    &.active {
        display: block;
        opacity: 1;
    }
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #e8d9bf;

    & h3 {
        margin: 0;
        color: #3f2c75;
        font-size: 20px;
        font-weight: 600;
    }
}

.mobile-menu-close {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    height: fit-content;
    line-height: normal;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-content {
    padding: 20px;
}

.mobile-menu-content .blogLink {
    color: #3f2c75;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 20px 0;

    &:hover {
        color: #efa61f;
    }
}

.mobile-actions {
    margin-top: 15px;
}

/* Mobile Categories */
.mobile-categories {
    & h4 {
        color: #3f2c75;
        font-size: 16px;
        font-weight: 600;
        margin: 0 0 12px 0;
    }
}

.mobile-categories-list {
    list-style: none;
    padding: 0;
    margin: 0;

    & li {
        margin-bottom: 4px;
    }

    & a {
        display: block;
        padding: 10px 12px;
        color: #3f2c75;
        text-decoration: none;
        border-radius: 4px;
        transition: background 0.2s;

        &:hover {
            background: #f5f5f5;
        }
    }

    & .has-children.active .mobile-category-toggle::after {
        transform: rotate(45deg);
    }
}

.mobile-category-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    color: #3f2c75;
    font-weight: 500;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 4px;
    text-align: left;

    &:hover {
        background: #f5f5f5;
    }

    &::after {
        content: '+';
        font-size: 18px;
        transition: transform 0.2s;
    }
}

.mobile-subcategories {
    display: none;
    list-style: none;
    padding-left: 20px;
    margin-top: 4px;

    & a {
        font-size: 14px;
        padding: 8px 12px;
    }
}

/* Mobile Actions */
.mobile-action-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: #3f2c75;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
    margin-bottom: 8px;
    position: relative;

    &:hover {
        background: #f5f5f5;
    }

    & span {
        font-weight: 500;
    }
}

.mobile-cart-count,
.mobile-wishlist-count {
    position: absolute !important;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #d83764;
    color: #fff;
    font-weight: 700;
    border-radius: 99px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Mobile Search */
.mobile-search {
    & form {
        display: flex;
        gap: 8px;
    }

    & input[type='search'] {
        flex: 1;
        padding: 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 14px;
    }

    & button {
        padding: 12px;
        background: #3f2c75;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;

        & svg {
            stroke: #fff;
        }
    }
}

/* RESPONSIVE */
@media (max-width: 1200px) {
    .header-actions {
        display: none;
    }

    .mobile-search button {
        color: #fff;

        & svg {
            stroke: #fff;
        }
    }

    .mobile-menu-toggle {
        display: flex;
        order: -1;
    }

    .header-search,
    .categories-dropdown,
    .header-actions .icon-link {
        display: none;
    }

    .custom-header .container {
        justify-content: space-between;
        gap: 1rem;
    }

    .header-logo {
        order: 0;
    }
}

@media (max-width: 768px) {
    .mobile-menu {
        width: 85%;
        max-width: 100%;
    }

    .header-logo {
        & img {
            max-height: 60px;
        }
    }
}
