/* Cart Sidebar Preview */
.cart-sidebar {
    position: fixed;
    right: 0;
    top: 75px; /* Começa abaixo do navbar */
    width: 400px;
    height: calc(100% - 75px);
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 20000 !important; /* Maximum priority */
    
    /* Animação da Sacola */
    transform: translateX(400px);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    display: flex;
    flex-direction: column;
}

.cart-sidebar.open {
    transform: translateX(0);
}

/* Overlay desabilitado */
.cart-sidebar-overlay {
    display: none;
}

/* Navbar e Header ficam fixos e NÃO se movem */
.header {
    position: sticky !important;
    top: 0;
    z-index: 1000 !important; /* Base z-index */
    background: white;
    width: 100%;
}

/* 
   MOVIMENTAÇÃO DO CONTEÚDO:
   Aplicamos a transição apenas nos blocos que estão na "raiz" do body.
   Isso evita o bug de deslocamento duplo.
*/
main, 
footer, 
.footer, 
body > .page-header,
body > .hero-banner, 
body > .banner-slider, 
body > .container, 
body > .main-container,
body > .banner-novidade-wrapper,
body > .tag-filters-wrapper {
    transition: margin-right 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Quando a sacola abre - Desktop: permite scroll vertical, esconde horizontal */
body.cart-sidebar-open {
    overflow-x: hidden;
}

/* 
   SINCRONIA:
   Empurramos apenas os elementos de primeiro nível.
   O Navbar (.header) não está nesta lista, então fica parado.
*/
body.cart-sidebar-open > main,
body.cart-sidebar-open > footer,
body.cart-sidebar-open > .footer,
body.cart-sidebar-open > .page-header,
body.cart-sidebar-open > .hero-banner,
body.cart-sidebar-open > .main-container,
body.cart-sidebar-open > .container,
body.cart-sidebar-open > .banner-novidade-wrapper,
body.cart-sidebar-open > .tag-filters-wrapper {
    margin-right: 400px !important;
    width: calc(100% - 400px) !important;
    max-width: none !important;
}

/* Ajuste específico para os controles do Linktree (Share/Theme) */
body.cart-sidebar-open .top-controls {
    margin-right: 400px !important;
}

/* No mobile, a sacola apenas sobrepõe, sem empurrar */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
        transform: translateX(100%);
        top: 0;
        height: 100%;
    }

    /* Mobile: Bloqueia scroll do body completamente */
    body.cart-sidebar-open {
        overflow: hidden;
        height: 100vh;
    }

    body.cart-sidebar-open > main,
    body.cart-sidebar-open > footer,
    body.cart-sidebar-open > .footer,
    body.cart-sidebar-open > .container,
    body.cart-sidebar-open > .page-header,
    body.cart-sidebar-open > .main-container,
    body.cart-sidebar-open > .hero-banner,
    body.cart-sidebar-open > .banner-novidade-wrapper {
        margin-right: 0 !important;
        width: 100% !important;
    }
}

/* Estilos internos da sacola */
.cart-sidebar-header {
    background: linear-gradient(135deg, var(--primary-green, #2d7a4f) 0%, var(--secondary-green, #3fa76b) 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-sidebar-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-sidebar-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.cart-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cart-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.cart-sidebar-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: transform 0.2s;
}

.cart-sidebar-item:hover {
    transform: translateX(-5px);
}

.cart-sidebar-item-image {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.cart-sidebar-item-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.02) 10px, rgba(0,0,0,0.02) 20px);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.cart-sidebar-item-placeholder img {
    width: 60%;
    height: auto;
    opacity: 0.5;
}

.cart-sidebar-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cart-sidebar-item-name {
    font-weight: 600;
    color: #2d7a4f;
    font-size: 0.95rem;
    line-height: 1.3;
}

.cart-sidebar-item-price {
    color: #666;
    font-size: 0.9rem;
}

.cart-sidebar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.cart-sidebar-qty-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 2px;
}

.sidebar-qty-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--primary-green, #2d7a4f);
    font-weight: 700;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-qty-btn:hover {
    background: #f0f0f0;
}

.sidebar-qty-val {
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.sidebar-remove-btn {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    font-size: 1rem;
    transition: color 0.2s;
}

.sidebar-remove-btn:hover {
    color: #dc3545;
}

.cart-sidebar-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: #999;
}

.cart-sidebar-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #ddd;
}

.cart-sidebar-empty p {
    margin: 0;
    font-size: 1rem;
}

.cart-sidebar-footer {
    padding: 1.5rem;
    background: #f8f9fa;
    border-top: 2px solid #e0e0e0;
}

.cart-sidebar-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.cart-sidebar-total span:last-child {
    color: var(--primary-green, #2d7a4f);
    font-size: 1.3rem;
}

.cart-sidebar-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-green, #2d7a4f) 0%, var(--secondary-green, #3fa76b) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.cart-sidebar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(45, 122, 79, 0.3);
    color: white;
}

/* Confirmation Modal */
.cart-confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30000; /* Higher than sidebar (20000) */
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.cart-confirmation-overlay.show {
    display: flex;
    opacity: 1;
}

.cart-confirmation-modal {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    width: 90%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cart-confirmation-overlay.show .cart-confirmation-modal {
    transform: scale(1);
}

.cart-confirmation-icon {
    width: 60px;
    height: 60px;
    background: #fee2e2;
    color: #dc3545;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.cart-confirmation-modal h3 {
    margin: 0 0 0.5rem;
    color: #2c3e50;
    font-size: 1.25rem;
}

.cart-confirmation-modal p {
    color: #666;
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.cart-confirmation-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.cart-confirmation-actions button {
    flex: 1;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    border: none;
    transition: all 0.2s;
}

.btn-cancel {
    background: #f1f3f5;
    color: #495057;
}

.btn-cancel:hover {
    background: #e9ecef;
}

.btn-confirm {
    background: #dc3545;
    color: white;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
}

.btn-confirm:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(220, 53, 69, 0.4);
}
