/* Cores Oficiais OfferSync: Laranja (#f97316 / #ea580c) e Azul (#1d4ed8 / #2563eb / #0f172a) */
:root {
    --offersync-blue: #1d4ed8;
    --offersync-blue-hover: #1e40af;
    --offersync-orange: #f97316;
    --offersync-orange-hover: #ea580c;
    --offersync-bg: #f8fafc;
}

/* Spinner de carregamento */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #f97316;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Animação de fade-in usada pelos modais */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.animate-fadeIn {
    animation: fadeIn 0.25s ease-out;
}

/* Ocultar barra de rolagem mantendo a funcionalidade de scroll */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Carrossel de Categorias em Linha Reta com Setas Estilizadas */
.carrossel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.carrossel-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 6px 4px;
    white-space: nowrap;
    width: 100%;
}

.carrossel-seta {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e293b;
    z-index: 20;
    cursor: pointer;
    transition: all 0.2s ease;
}

.carrossel-seta:hover {
    background-color: #1d4ed8;
    color: #ffffff;
    border-color: #1d4ed8;
    transform: translateY(-50%) scale(1.08);
}

.carrossel-seta.seta-esquerda {
    left: -14px;
}

.carrossel-seta.seta-direita {
    right: -14px;
}

/* ── Carrossel de Produtos (estilo Mercado Livre) ────────────── */
.carrossel-produtos {
    gap: 14px;
    padding: 6px 6px 16px;
}

.carrossel-produtos .produto-card {
    flex: 0 0 260px;
    width: 260px;
    scroll-snap-align: start;
}

.carrossel-produtos .produto-img-container {
    height: 200px;
}

/* Botão "Ver todos" do cabeçalho da seção */
.ver-todos-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 9999px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.ver-todos-btn:hover {
    background-color: #eff6ff;
    color: #1e40af;
}

.ver-todos-btn span {
    font-size: 1rem;
    line-height: 1;
}

/* Botões de Categorias (Pills modernas) */
.categoria-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 9999px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    user-select: none;
}

.categoria-pill:hover {
    border-color: #f97316;
    color: #ea580c;
    background-color: #fff7ed;
    transform: translateY(-1px);
}

.categoria-pill.ativo {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: #ffffff;
    border-color: #1d4ed8;
    box-shadow: 0 4px 10px rgba(29, 78, 216, 0.25);
}

/* Barra de Pesquisa Inteligente Estilo Google */
.busca-container {
    position: relative;
    width: 100%;
}

.busca-input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 9999px;
    padding: 6px 14px;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.busca-input-wrapper:focus-within {
    border-color: #f97316;
    box-shadow: 0 4px 18px rgba(249, 115, 22, 0.18);
}

.busca-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    z-index: 50;
    max-height: 420px;
    overflow-y: auto;
}

.sugestao-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f1f5f9;
}

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

.sugestao-item:hover, .sugestao-item.ativo {
    background-color: #f8fafc;
}

/* Badge de desconto */
.desconto-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1.2;
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.35);
    z-index: 10;
}

/* Card de produto estilo Mercado Livre - Proporção Perfeita sem Esticar nem Cortar */
.produto-card {
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    content-visibility: auto;
    contain-intrinsic-size: 260px 420px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.produto-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

/* Container de Imagem: Garante que fotos nunca sejam cortadas nem esticadas */
.produto-img-container {
    position: relative;
    width: 100%;
    height: 220px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    overflow: hidden;
    border-bottom: 1px solid #f1f5f9;
}

.produto-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.produto-card:hover .produto-img {
    transform: scale(1.04);
}

/* Card de cupom - hover */
.cupom-card {
    transition: all 0.2s ease;
    border-radius: 12px;
}
.cupom-card:hover {
    border-color: #f97316;
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.1);
}

/* Código do cupom (cursor pointer para cópia) */
.cupom-codigo {
    cursor: pointer;
    user-select: all;
    transition: background-color 0.2s;
}
.cupom-codigo:hover {
    background-color: #ffedd5;
}

/* Feedback de cópia */
.copiado-feedback {
    animation: fadeOut 1.5s forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Alerta global */
#global-alert.success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

#global-alert.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── Dark Mode Específico da Vitrine ──────────────────────────── */
html.dark {
    color-scheme: dark;
}

html.dark body {
    background-color: #020617;
    color: #f8fafc;
}

html.dark .produto-card {
    background-color: #0f172a;
    border-color: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

html.dark .produto-card:hover {
    border-color: #334155;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

html.dark .produto-img-container {
    background-color: #0f172a;
    border-color: #1e293b;
}

html.dark .categoria-pill {
    background-color: #0f172a;
    border-color: #1e293b;
    color: #cbd5e1;
}

html.dark .categoria-pill:hover {
    border-color: #ea580c;
    color: #fdba74;
    background-color: #1e293b;
}

html.dark .categoria-pill.ativo {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

html.dark .carrossel-seta {
    background-color: #0f172a;
    border-color: #1e293b;
    color: #f1f5f9;
}

html.dark .carrossel-seta:hover {
    background-color: #1d4ed8;
    color: #ffffff;
    border-color: #1d4ed8;
}

html.dark .ver-todos-btn {
    color: #60a5fa;
}

html.dark .ver-todos-btn:hover {
    background-color: #1e293b;
    color: #93c5fd;
}

html.dark .busca-input-wrapper {
    background-color: #0f172a;
    border-color: #334155;
}

html.dark .busca-input-wrapper:focus-within {
    border-color: #f97316;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.25);
}

html.dark .busca-dropdown {
    background-color: #0f172a;
    border-color: #1e293b;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

html.dark .sugestao-item {
    border-color: #1e293b;
    color: #e2e8f0;
}

html.dark .sugestao-item:hover, html.dark .sugestao-item.ativo {
    background-color: #1e293b;
}

html.dark .cupom-card {
    background-color: #0f172a;
    border-color: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html.dark .cupom-card:hover {
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

html.dark .cupom-codigo {
    color: #60a5fa;
}

/* Transições suaves e responsividade da galeria do modal */
#modal-produto-img-principal {
    transition: opacity 0.15s ease-in-out, transform 0.25s ease-out;
}

#modal-galeria-miniaturas::-webkit-scrollbar {
    height: 4px;
}
#modal-galeria-miniaturas::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
html.dark #modal-galeria-miniaturas::-webkit-scrollbar-thumb {
    background: #334155;
}

/* ── Otimizações Específicas para Mobile ──────────────────────── */
.safe-area-pb {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
}

@media (max-width: 640px) {
    body {
        padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
    }

    /* Evita auto-zoom do iOS em inputs ao focar */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Reduz atraso de 300ms de toque em dispositivos móveis */
    button, a, .produto-card, .categoria-pill, .sugestao-item {
        touch-action: manipulation;
    }

    .carrossel-track {
        gap: 10px;
        padding: 4px 4px 8px 4px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        overscroll-behavior-x: contain;
    }

    .categoria-pill {
        padding: 8px 16px;
        font-size: 0.85rem;
        scroll-snap-align: start;
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .categoria-pill:active {
        transform: scale(0.95);
    }

    .carrossel-produtos {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        overscroll-behavior-x: contain;
        touch-action: pan-x pan-y;
        padding-bottom: 6px;
    }

    .carrossel-produtos .produto-card {
        flex-basis: 212px;
        width: 212px;
        min-width: 212px;
        scroll-snap-align: start;
        scroll-snap-stop: normal;
        border-radius: 16px;
    }

    .carrossel-produtos .produto-card:active {
        transform: scale(0.98);
    }

    .carrossel-produtos .produto-img-container {
        height: 170px;
        padding: 8px;
    }

    .carrossel-seta {
        display: none; /* No mobile, o swipe tátil nativo com snap é muito mais fluido */
    }

    .produto-img-container {
        height: 190px;
        padding: 10px;
    }

    /* Botão de favorito com touch target confortável */
    .btn-card-favorito {
        width: 38px !important;
        height: 38px !important;
    }

    .busca-input-wrapper {
        padding: 6px 14px;
        border-radius: 9999px;
    }

    #busca-submit-btn {
        padding: 6px 14px;
        font-size: 0.84rem;
        min-height: 36px;
    }

    /* Animação estilo Bottom Sheet nos modais */
    @keyframes slideUpModalSheet {
        from {
            transform: translateY(100%);
            opacity: 0.85;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    #produto-detalhes-modal > div:last-child > div,
    #modal-auth-usuario > div:last-child,
    #modal-favoritos-shopee > div:last-child,
    #modal-perfil-mobile > div:last-child > div {
        animation: slideUpModalSheet 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    /* Botão Flutuante Voltar ao Topo no Mobile (acima da Bottom Navigation Bar) */
    #btn-voltar-topo {
        bottom: 5.25rem !important;
        right: 1rem !important;
    }
}

/* Botão Flutuante Voltar ao Topo */
#btn-voltar-topo {
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(29, 78, 216, 0.35);
}

#btn-voltar-topo:hover {
    box-shadow: 0 6px 24px rgba(29, 78, 216, 0.5);
}