:root {
    --cor-laranja:        #f97316;
    --cor-laranja-escuro: #ea580c;
    --dark-fundo:         #121212;
    --dark-card:          #1a1a1a;
    --dark-card-alt:      #202020;
    --dark-borda:         #2a2a2a;
    --dark-borda-clara:   #333333;
    --dark-hover:         #252525;
    --raio-input:         0.875rem;
    --easing-suave:       cubic-bezier(0.4, 0, 0.2, 1);
    --easing-elastico:    cubic-bezier(0.34, 1.56, 0.64, 1);
    --duracao-reveal:     0.55s;
}

/* ======================================================
   2. RESET BASE
   ====================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* PERMISSÕES GLOBAIS */
body, * {
    -webkit-touch-callout: default;
}
#videoPlayer, #shopeeUrl, .allow-select, input, textarea, p, span, h1, h2, h3, h4 {
    user-select: auto !important;
    -webkit-user-select: auto !important;
}
.proteger-selecao {
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

/* Scroll bloqueado */
body.modal-aberto { overflow: hidden; }
input[type="text"] { -webkit-appearance: none; }

/* ======================================================
   3. SCROLLBAR LARANJA
   ====================================================== */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cor-laranja-escuro); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--cor-laranja); }

/* ======================================================
   4. DARK MODE
   ====================================================== */
html.dark body { background-color: var(--dark-fundo) !important; }
html.dark .dark\:bg-darkcard   { background-color: var(--dark-card) !important; }
html.dark .dark\:bg-slate-900  { background-color: var(--dark-card) !important; }
html.dark .dark\:bg-slate-800  { background-color: var(--dark-card-alt) !important; }
html.dark .dark\:bg-slate-950  { background-color: #0e0e0e !important; }
html.dark .dark\:border-slate-700 { border-color: var(--dark-borda) !important; }
html.dark .dark\:border-slate-800 { border-color: var(--dark-borda) !important; }
html.dark .dark\:hover\:bg-slate-800:hover { background-color: var(--dark-hover) !important; }

/* ======================================================
   5. INPUT
   ====================================================== */
.input-arredondado { border-radius: var(--raio-input); }

/* LIMPAR INPUT */
   
.btn-limpar-input {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    z-index: 2;
    flex-shrink: 0;
}
.btn-limpar-input:hover {
    background: rgba(234, 88, 12, 0.12);
    color: var(--cor-laranja-escuro);
}
html.dark .btn-limpar-input {
    background: rgba(255,255,255,0.08);
    color: #94a3b8;
}
html.dark .btn-limpar-input:hover {
    background: rgba(249,115,22,0.12);
    color: var(--cor-laranja);
}
/* função vendedor beta */
.switch-track { transition: background-color 0.25s ease; }
.switch-knob { transition: transform 0.28s var(--easing-elastico); }

.resultado-header-flex { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
@media (max-width: 480px) {
    .resultado-header-flex { flex-direction: column; align-items: flex-start; }
    .btn-nova-busca-mobile { align-self: flex-end; margin-top: -38px; }
}

/* AVISO JÁ BAIXADO  */
#avisoJaBaixado {
    animation: fadeInDown 0.2s ease forwards;
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* AVISO DOWNLOAD ATIVO */
#avisoDownloadAtivo {
    position: fixed;
    top: 64px; left: 0; right: 0;
    z-index: 49;
    padding: 5px 16px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    background: rgba(234, 88, 12, 0.08);
    border-bottom: 1px solid rgba(234, 88, 12, 0.18);
    color: var(--cor-laranja-escuro);
    transition: opacity 0.2s ease;
}
html.dark #avisoDownloadAtivo {
    background: rgba(234, 88, 12, 0.06);
    color: var(--cor-laranja);
}

/* ======================================================
   6. NOTIFICAÇÕES
   ====================================================== */
@keyframes entrarToast {
    from { transform: translateY(10px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1);       opacity: 1; }
}
@keyframes sairToast {
    from { transform: translateY(0) scale(1);       opacity: 1; }
    to   { transform: translateY(8px) scale(0.96);  opacity: 0; }
}
.toast-enter  { animation: entrarToast 0.22s var(--easing-elastico) forwards; }
.toast-saindo { animation: sairToast   0.18s ease-in forwards; }

.toast-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    pointer-events: auto;
    cursor: pointer;
    white-space: nowrap;
    max-width: 90vw;
}
.toast-sucesso {
    background: rgba(22,163,74,0.1);
    border-color: rgba(22,163,74,0.25);
    color: #15803d;
}
html.dark .toast-sucesso {
    color: #4ade80;
    background: rgba(74,222,128,0.07);
    border-color: rgba(74,222,128,0.18);
}
.toast-erro {
    background: rgba(220,38,38,0.08);
    border-color: rgba(220,38,38,0.2);
    color: #b91c1c;
}
html.dark .toast-erro {
    color: #f87171;
    background: rgba(248,113,113,0.07);
    border-color: rgba(248,113,113,0.18);
}
.toast-aviso {
    background: rgba(249,115,22,0.08);
    border-color: rgba(249,115,22,0.22);
    color: var(--cor-laranja-escuro);
}
html.dark .toast-aviso {
    color: var(--cor-laranja);
    background: rgba(249,115,22,0.07);
    border-color: rgba(249,115,22,0.18);
}

/* ======================================================
   7. HEADER INTELIGENTE
   ====================================================== */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    transition: transform 0.3s var(--easing-suave),
                box-shadow 0.3s ease;
}
html.dark header {
    background-color: var(--dark-fundo);
    border-bottom-color: var(--dark-borda);
}
header.header-escondido { transform: translateY(-100%); }
header.header-elevado   { box-shadow: 0 4px 20px rgba(0,0,0,0.06); }
html.dark header.header-elevado { box-shadow: 0 4px 20px rgba(0,0,0,0.4); }

/* ======================================================
   8. MENU MOBILE
   ====================================================== */
.menu-mobile {
    transform: translateX(100%);
    transition: transform 0.3s var(--easing-suave);
    background-color: #ffffff;
}
html.dark .menu-mobile {
    background-color: var(--dark-fundo) !important;
    border-left: 1px solid var(--dark-borda);
}
.menu-mobile.menu-aberto { transform: translateX(0); }

/* ======================================================
   9. SCROLL REVEAL
   ====================================================== */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity var(--duracao-reveal) var(--easing-suave),
                transform var(--duracao-reveal) var(--easing-suave);
}
.reveal.revelado { opacity: 1; transform: translateY(0); }
.reveal[data-atraso="1"] { transition-delay: 0.05s; }
.reveal[data-atraso="2"] { transition-delay: 0.10s; }
.reveal[data-atraso="3"] { transition-delay: 0.15s; }

/* ======================================================
   10. LOADER
   ====================================================== */
#loader > div { animation: entrarLoader 0.4s var(--easing-elastico) forwards; }
@keyframes entrarLoader {
    from { transform: scale(0.92) translateY(12px); opacity: 0; }
    to   { transform: scale(1) translateY(0);       opacity: 1; }
}
.loader-icone-wrapper {
    width: 72px; height: 72px;
    background: rgba(249,115,22,0.12);
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
}
.loader-spinner {
    width: 36px; height: 36px;
    border: 4px solid rgba(249,115,22,0.15);
    border-top-color: var(--cor-laranja);
    border-radius: 50%;
    animation: girarSpinner 0.85s linear infinite;
}
@keyframes girarSpinner { to { transform: rotate(360deg); } }

.barra-fundo {
    height: 4px;
    background: rgba(249,115,22,0.12);
    border-radius: 99px;
    overflow: hidden;
}
.barra-preenchimento {
    height: 100%; width: 0;
    background: linear-gradient(90deg, var(--cor-laranja-escuro), var(--cor-laranja));
    border-radius: 99px;
    animation: preencherBarra 3.8s ease-in-out forwards;
}
@keyframes preencherBarra {
    0%  { width: 0%;  } 30% { width: 35%; }
    60% { width: 65%; } 85% { width: 82%; }
    100%{ width: 94%; }
}

/* ======================================================
   11. PASSOS DO CARREGAMENTO
   ====================================================== */
.passo-carregamento {
    display: flex; flex-direction: column; align-items: center;
    gap: 5px; font-size: 11px; font-weight: 700;
    text-align: center; min-width: 72px;
}
.passo-badge {
    display: inline-flex; align-items: center; justify-content: center;
    height: 30px; padding: 0 12px; border-radius: 99px;
    border: 2px solid var(--dark-borda);
    font-size: 11px; font-weight: 700;
    background: transparent; color: #64748b;
    transition: all 0.4s ease; white-space: nowrap;
}
html:not(.dark) .passo-badge { border-color: #e2e8f0; color: #94a3b8; }
.passo-ativo .passo-badge {
    background: rgba(249,115,22,0.12);
    border-color: var(--cor-laranja);
    color: var(--cor-laranja);
    animation: pulsarPasso 1.4s ease-in-out infinite;
}
/* Para de pulsar quando concluído */
.passo-concluido .passo-badge {
    background: rgba(34,197,94,0.1);
    border-color: #22c55e; color: #22c55e;
    animation: none !important;
}
@keyframes pulsarPasso {
    0%,100% { transform: scale(1);    box-shadow: 0 0 0 0   rgba(249,115,22,0.3); }
    50%      { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(249,115,22,0);   }
}
.passo-linha {
    flex: 1; height: 2px; border-radius: 1px;
    background: #e2e8f0; align-self: center;
}
html.dark .passo-linha { background: var(--dark-borda); }

/* ======================================================
   12. BARRA DE PROGRESSO DO DOWNLOAD (verde)
   ====================================================== */
#barraDownloadFill {
    height: 100%;
    background: linear-gradient(90deg, #16a34a, #22c55e);
    border-radius: 99px;
    width: 0;
    transition: width 0.3s ease;
}

/* ======================================================
   13. HISTÓRICO
   ====================================================== */
   .hist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    transition: border-color 0.15s ease;
}
html.dark .hist-item {
    border-color: var(--dark-borda);
    background: var(--dark-card);
}
html.dark .hist-item:hover { border-color: var(--dark-borda-clara); }

.hist-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.hist-num {
    flex-shrink: 0;
    width: 16px;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    display: flex; 
    align-items: center; 
    justify-content: center;
}
html.dark .hist-num { color: #94a3b8; }

/* Novo visual do Thumbnail no histórico */
.hist-thumb-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background-color: #e2e8f0;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.05);
}
html.dark .hist-thumb-wrapper { border-color: rgba(255,255,255,0.05); }

.hist-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.hist-thumb-wrapper:hover .hist-play-overlay { opacity: 1; }

.hist-info { 
    min-width: 0; 
    flex: 1; 
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Agrupamento da direita (copiar + download) */
.hist-actions-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Botão de copiar legenda do histórico */
.hist-btn-acao {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(249,115,22,0.1);
    color: var(--cor-laranja-escuro);
    border: 1px solid rgba(249,115,22,0.2);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}
html.dark .hist-btn-acao {
    background: rgba(249,115,22,0.08);
    color: var(--cor-laranja);
}
.hist-btn-acao:hover:not(.inativo) {
    background: rgba(249,115,22,0.2);
}
.hist-btn-acao.inativo {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(1);
}
.hist-link {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: #0284c7;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    transition: color 0.15s ease;
}
.hist-link:hover { color: #0369a1; text-decoration: underline; }
html.dark .hist-link { color: #38bdf8; }
html.dark .hist-link:hover { color: #7dd3fc; }
.hist-data { font-size: 10px; color: #94a3b8; margin-top: 1px; display: block; }

/* Botão baixar do histórico */
.hist-btn {
    flex-shrink: 0;
    position: relative;
    height: 30px;
    min-width: 72px;
    border-radius: 8px;
    border: none;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    color: white;
    background: #16a34a;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background 0.2s ease, opacity 0.2s ease;
    padding: 0 10px;
}
.hist-btn:hover:not(:disabled) { background: #15803d; }
.hist-btn:disabled { cursor: default; }

/* Preenchimento de progresso verde interno */
.hist-btn-prog {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: rgba(255,255,255,0.22);
    width: 0%;
    transition: width 0.3s ease;
    pointer-events: none;
    border-radius: 8px;
}
.hist-btn-label {
    position: relative;
    z-index: 1;
    pointer-events: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Estados do botão histórico */
.hist-btn.estado-fila       { background: #7c3aed; }
.hist-btn.estado-cronometro { background: #7c3aed; }
.hist-btn.estado-baixando   { background: #16a34a; cursor: default; }
.hist-btn.estado-cooldown   { background: #dc2626; cursor: not-allowed; }
html.dark .hist-btn.estado-cooldown { background: #b91c1c; }

/* Botão X cancelar no histórico */
.hist-cancel {
    flex-shrink: 0;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: rgba(239,68,68,0.08);
    color: #ef4444;
    border: 1px solid rgba(239,68,68,0.2);
    font-size: 9px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
}
.hist-cancel.visivel { display: flex; }
.hist-cancel:hover { background: rgba(239,68,68,0.18); }

/* ======================================================
   14. COMO FUNCIONA
   ============================================== */
.passo-numero {
    width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, var(--cor-laranja-escuro), var(--cor-laranja));
    color: white; font-size: 24px; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 28px rgba(249,115,22,0.35);
    transition: transform 0.3s var(--easing-elastico), box-shadow 0.3s ease;
    flex-shrink: 0; user-select: none;
}
.passo-item:hover .passo-numero {
    transform: scale(1.1) rotate(-3deg);
    box-shadow: 0 14px 36px rgba(249,115,22,0.45);
}

/* ======================================================
   15. FAQ
   ====================================================== */
.faq-resposta { display: none; padding-top: 0.75rem; }
.faq-item.faq-aberto .faq-resposta { display: block; }
.faq-item.faq-aberto .faq-seta { transform: rotate(180deg); }
.faq-seta { transition: transform 0.3s var(--easing-suave); flex-shrink: 0; }
.faq-item { cursor: pointer; transition: box-shadow 0.25s ease; }
.faq-item:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.07); }

/* ======================================================
   16. MODAL
   ====================================================== */
.modal-conteudo {
    animation: entrarModal 0.3s var(--easing-elastico) forwards;
}
@keyframes entrarModal {
    from { transform: scale(0.9) translateY(16px); opacity: 0; }
    to   { transform: scale(1) translateY(0);      opacity: 1; }
}
html.dark .modal-conteudo {
    background-color: var(--dark-card) !important;
    border-color: var(--dark-borda) !important;
}
/* Flex helper para modais */
.modal-flex { display: flex !important; }

/* ======================================================
   17. FOOTER
   ====================================================== */
footer {
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
}
html.dark footer {
    background-color: #0e0e0e !important;
    border-top-color: var(--dark-borda) !important;
}

/* ======================================================
   18. BOTÃO VOLTAR AO TOPO
   ====================================================== */
#btnVoltarTopo {
    position: fixed;
    bottom: 5rem; right: 1.25rem;
    z-index: 40;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--cor-laranja-escuro);
    color: white; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(234,88,12,0.4);
    opacity: 0; pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
#btnVoltarTopo.visivel { opacity: 1; pointer-events: auto; transform: translateY(0); }
#btnVoltarTopo:hover   { background: var(--cor-laranja); }

/* ======================================================
   19. BANNER LGPD
   ====================================================== */
#lgpdBanner {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 38;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid #e2e8f0;
    transition: transform 0.4s var(--easing-suave);
}
html.dark #lgpdBanner {
    background: rgba(18,18,18,0.96);
    border-top-color: var(--dark-borda);
}
#lgpdBanner.lgpd-escondido { transform: translateY(100%); }

/* ======================================================
   20. BOTÃO COPIAR DESCRIÇÃO
   ====================================================== */
.btn-copiar-descricao {
    opacity: 1 !important;
    background: rgba(249,115,22,0.1);
    border: 1px solid rgba(249,115,22,0.3);
    color: var(--cor-laranja-escuro);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; gap: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}
html.dark .btn-copiar-descricao {
    background: rgba(249,115,22,0.08);
    border-color: rgba(249,115,22,0.25);
    color: var(--cor-laranja);
}
.btn-copiar-descricao:hover { background: rgba(249,115,22,0.18); }

/* ======================================================
   21. CHECKBOX TERMOS
   ====================================================== */
.checkbox-termos {
    accent-color: var(--cor-laranja);
    width: 16px; height: 16px;
    cursor: pointer; flex-shrink: 0;
}

/* ======================================================
   22. RESPONSIVIDADE MOBILE
   ====================================================== */
@media (max-width: 640px) {
    html { font-size: 80%; }
    #loader > div { padding: 1.25rem; }
    .loader-icone-wrapper { width: 58px; height: 58px; border-radius: 16px; }
    .loader-spinner       { width: 28px; height: 28px; }
    .passo-carregamento   { font-size: 10px; min-width: 58px; }
    .passo-badge          { height: 26px; padding: 0 8px; font-size: 10px; }
    .passo-numero         { width: 54px; height: 54px; font-size: 20px; }
    #btnVoltarTopo        { bottom: 6rem; right: 1rem; width: 40px; height: 40px; }
    .toast-item           { font-size: 11px; padding: 7px 13px; }
    .hist-item            { flex-wrap: wrap; }
}
