/* ===========================================================================
   MODAL CENTRAL (DESAFIO -> CARREGANDO -> RESULTADO), USADO COM alert-sami.js.
   ⚠ COMPONENTE COMPARTILHADO ENTRE SITES: CONSERTO FEITO AQUI TEM DE VOLTAR PARA
   AS OUTRAS CÓPIAS. O QUE É DE CADA SITE VEM DE VARIÁVEIS COM FALLBACK:
   `--fonte` (FONTE DO SITE) E `--cor-destaque` (COR DO SPINNER).
   SUCESSO E ERRO USAM VERDE/VERMELHO FIXOS, NUNCA A COR DO SITE.
   TODO O HTML É CRIADO PELO JS; ÍCONES DE SUCESSO/ERRO SÃO SÓ CSS.
   =========================================================================== */

.alert-sami {
    position: fixed;
    inset: 0;
    /* ⚠ ACIMA DE TUDO QUE O SITE EMPILHA (O POPUP DO PAINEL É 10001): O MODAL
       RESPONDE A UMA AÇÃO DO VISITANTE E NÃO PODE FICAR ATRÁS DE NADA. */
    z-index: 10002;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    /* FONTE DO SITE; SEM A VARIÁVEL, A DO SISTEMA. */
    font-family: var(--fonte, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif);
}

.alert-sami[hidden] { display: none; }

.alert-sami__fundo {
    position: absolute;
    inset: 0;
    background: rgb(37 37 37 / 60%);
    opacity: 0;
    transition: opacity .2s ease;
}

.alert-sami--visivel .alert-sami__fundo { opacity: 1; }

.alert-sami__caixa {
    position: relative;
    z-index: 1;
    width: min(360px, 100%);
    padding: 2rem 1.5rem 1.5rem;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    text-align: center;
    opacity: 0;
    transform: translateY(12px) scale(.98);
    transition: opacity .2s ease, transform .2s ease;
}

.alert-sami--visivel .alert-sami__caixa {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.alert-sami__x {
    position: absolute;
    top: .6rem;
    right: .6rem;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 50%;
    background: none;
    color: #8a8f9c;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}

.alert-sami__x:hover { color: #1f2430; border-color: rgba(15, 23, 42, .3); }

/* NO CARREGANDO NÃO HÁ COMO DESISTIR (O ENVIO JÁ SAIU): O X SOME. */
.alert-sami__caixa--carregando .alert-sami__x { display: none; }

/* --- PASSO 1 (OPCIONAL): DESAFIO TURNSTILE ---------------------------------
   O WIDGET SE DESENHA SOZINHO AQUI. A MARGEM DE CIMA EVITA QUE O X COBRE O CANTO DELE. */
.alert-sami__desafio {
    display: none;
    justify-content: center;
    min-height: 65px;
    margin: 1.5rem 0 .25rem;
}

.alert-sami__caixa--desafio .alert-sami__desafio { display: flex; }

/* --- PASSO 2: CARREGANDO, SPINNER NA COR DE DESTAQUE DO SITE --------------- */
.alert-sami__spinner {
    display: none;
    width: 34px;
    height: 34px;
    margin: 0 auto 1rem;
    border: 3px solid rgba(15, 23, 42, .1);
    /* COR DE DESTAQUE DO SITE; SEM ELA, `--cor-primaria`; SEM AS DUAS, AZUL. */
    border-top-color: var(--cor-destaque, var(--cor-primaria, #2563eb));
    border-radius: 50%;
    animation: alertSamiGirar .7s linear infinite;
}

.alert-sami__caixa--carregando .alert-sami__spinner { display: block; }

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

/* --- PASSO 3: RESULTADO, ÍCONE DESENHADO SÓ COM CSS ------------------------ */
.alert-sami__icone {
    display: none;
    position: relative;
    width: 44px;
    height: 44px;
    margin: 0 auto 1rem;
    border-radius: 50%;
}

.alert-sami__caixa--sucesso .alert-sami__icone,
.alert-sami__caixa--erro .alert-sami__icone {
    display: block;
}

.alert-sami__icone--sucesso { background: #22c55e; }
.alert-sami__icone--erro    { background: #ef4444; }

.alert-sami__icone--sucesso::after {
    content: '';
    position: absolute;
    left: 13px;
    top: 21px;
    width: 17px;
    height: 9px;
    border-left: 3px solid #fff;
    border-bottom: 3px solid #fff;
    transform: rotate(-45deg);
}

.alert-sami__icone--erro::before,
.alert-sami__icone--erro::after {
    content: '';
    position: absolute;
    left: 11px;
    top: 20px;
    width: 22px;
    height: 3px;
    background: #fff;
}

.alert-sami__icone--erro::before { transform: rotate(45deg); }
.alert-sami__icone--erro::after  { transform: rotate(-45deg); }

.alert-sami__texto {
    margin: 0;
    font-size: .95rem;
    line-height: 1.5;
    color: #1f2430;
}

/* --- ESTADO "INFO": TEXTO PARA LER, NÃO RESULTADO DE AÇÃO -------------------
   A CAIXA CRESCE, O TEXTO ALINHA À ESQUERDA E ROLA SE PASSAR DE 60% DA TELA. */
.alert-sami__caixa--info {
    width: min(560px, 100%);
    text-align: left;
}

.alert-sami__caixa--info .alert-sami__texto {
    max-height: 60vh;
    overflow-y: auto;
    font-size: 1rem;
}

/* --- BOTÃO OK: SÓ NO RESULTADO --------------------------------------------------
   ESCURO E NEUTRO DE PROPÓSITO: DÁ CONTRASTE EM QUALQUER COR DE SITE. */
.alert-sami__ok {
    display: none;
    margin-top: 1.25rem;
    padding: .65rem 2rem;
    border: 0;
    border-radius: 8px;
    background: #1f2430;
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}

.alert-sami__caixa--sucesso .alert-sami__ok,
.alert-sami__caixa--erro .alert-sami__ok {
    display: inline-block;
}

.alert-sami__ok:hover { background: #333a4a; }

/* TRAVA A ROLAGEM DO FUNDO ENQUANTO O MODAL ESTÁ ABERTO. */
body.alert-sami-aberto { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .alert-sami__spinner { animation-duration: 1.4s; }
    .alert-sami__fundo,
    .alert-sami__caixa { transition: none; }
}
