/**
 * Melhorias visuais para o carrinho
 * Estilos otimizados para fornecer feedback visual durante operações do carrinho
 */

/* Variáveis da nova paleta de cores */
:root {
    --bg-principal: #f0ece4;      /* fundo principal */
    --bg-secundario: #c7bca9;     /* fundo secundário */
    --cta-botoes: #ed3237;        /* botões e call-to-action */
    --fontes: #1e1d1c;           /* cor das fontes */
    
    /* Estados e alertas */
    --success-bg: #e8f5e8;
    --warning-bg: #fff8e1;
    --error-bg: #ffebee;
}

/* Estilo para item em processo de remoção */
.cart-item.removing {
    opacity: 0.5;
    position: relative;
    transform: translateX(5px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.cart-item.removing::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.5) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>') no-repeat center center;
    background-size: 20px;
    z-index: 2;
}

/* Estilo para área do carrinho em carregamento */
#cart-items.loading {
    position: relative;
    min-height: 100px;
    opacity: 0.7;
}

#mini-cart.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="38" height="38" viewBox="0 0 38 38" stroke="%232196F3"><g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/><path d="M36 18c0-9.94-8.06-18-18-18" transform="rotate(113.063 18 18)"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="1s" repeatCount="indefinite"/></path></g></g></svg>') no-repeat center center;
    z-index: 10;
}

/* Animação para adição de item ao carrinho */
@keyframes cartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Estilo para item recém-adicionado ao carrinho */
.cart-item.just-added {
    background-color: var(--success-bg);
    padding: 10px;
    border-radius: 4px;
    animation: highlightNew 1.5s ease-out;
}

.cart-item-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    font-style: italic;
    color: var(--bg-secundario);
}

.cart-item-loading:before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--bg-secundario);
    border-top-color: var(--cta-botoes);
    border-radius: 50%;
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

@keyframes highlightNew {
    0% { background-color: rgba(70, 180, 80, 0.2); }
    100% { background-color: transparent; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.added_to_cart_notification {
    animation: cartPulse 0.5s ease;
}

/* Animação para abertura do mini carrinho */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Melhorias de responsividade e velocidade */
#mini-cart {
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    will-change: transform, opacity;
}

#mini-cart.active {
    transform: translateX(0);
    opacity: 1;
    animation: slideIn 0.3s ease-out forwards;
}

/* Botões de ação no carrinho com feedback tátil */
.cart-item-remove, 
.button.add_to_cart_button {
    transition: all 0.2s ease;
    cursor: pointer;
    will-change: transform;
}

.cart-item-remove:hover {
    color: var(--color-accent);
}

.cart-item-remove:active, 
.button.add_to_cart_button:active {
    transform: scale(0.95);
}

/* Feedback visual para botão Adicionar ao Carrinho */
.button.add_to_cart_button.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.button.add_to_cart_button.loading::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(255,255,255,0.5) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>') no-repeat center center;
    background-size: 20px;
}

/* Estilização dos itens do carrinho para carregamento mais rápido */
.cart-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--bg-secundario);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateX(0);
}

.cart-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    margin-right: 10px;
    transition: opacity 0.3s ease;
    border-radius: 3px;
}

.cart-item-info {
    flex-grow: 1;
}

/* Otimização para dispositivos móveis */
@media (max-width: 768px) {
    #mini-cart {
        width: 90%;
        max-width: 320px;
    }
    
    .cart-item img {
        width: 50px;
        height: 50px;
    }
    
    .cart-item-info {
        font-size: 14px;
    }
}

/* Otimizações para carrinho vazio */
.empty-cart {
    text-align: center;
    padding: 20px;
    color: #6d6d6d;
    font-style: italic;
}

/* Melhorias de performance */
#mini-cart, .cart-item, .button.add_to_cart_button {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Notificação de carrinho vazio */
.cart-empty-notice {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 10px 20px;
    border-radius: 4px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease-out;
    background-color: var(--bg-principal);
    color: var(--fontes);
    border: 1px solid var(--bg-secundario);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Estilos de fallback para o mini-cart */
.cart-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 350px;
    max-width: 100%;
    background: var(--bg-principal);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    z-index: 9999;
    overflow-y: auto;
    border-left: 1px solid var(--bg-secundario);
}

#mini-cart:not(.active) {
    display: none;
}

/* Estilos para mensagem de erro no carrinho */
.cart-error {
    color: var(--cta-botoes);
    text-align: center;
    padding: 10px;
    margin-top: 10px;
}
