/* Portal do cliente do DHelp. Sem framework: a página tem que abrir rápido em
   conexão ruim e rodar dentro do WebView do software, onde não dá pra contar
   com CDN nem com bundler. */

:root {
    --marca: #0d9488;
    --marca-forte: #0f766e;
    --marca-clara: #10b981;
    --fundo: #f1f5f9;
    --painel: #ffffff;
    --painel-2: #f8fafc;
    --borda: #e2e8f0;
    --texto: #0f172a;
    --texto-2: #64748b;
    --bolha-op: #ffffff;
    --perigo: #b91c1c;
    --perigo-fundo: #fef2f2;
    --raio: 14px;
    --sombra: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --fundo: #020617;
        --painel: #0f172a;
        --painel-2: #0b1222;
        --borda: #1e293b;
        --texto: #e2e8f0;
        --texto-2: #94a3b8;
        --bolha-op: #1e293b;
        --perigo: #fca5a5;
        --perigo-fundo: rgba(153, 27, 27, .25);
        --sombra: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    }
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--fundo);
    color: var(--texto);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.min0 { min-width: 0; }

.tela { min-height: 100dvh; }

.centro {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px 16px;
}

/* ---------- carregando ---------- */

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--borda);
    border-top-color: var(--marca);
    animation: girar .8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2.4s; }
}

.dica { color: var(--texto-2); font-size: 13px; margin: 0; }

/* ---------- identificação ---------- */

.cartao {
    width: 100%;
    max-width: 420px;
    background: var(--painel);
    border: 1px solid var(--borda);
    border-radius: 20px;
    box-shadow: var(--sombra);
    padding: 24px;
}

.cartao-topo { margin-bottom: 20px; }

.marca { display: flex; align-items: center; gap: 12px; }

.marca h1 { font-size: 17px; margin: 0; font-weight: 700; }
.marca p { font-size: 12.5px; margin: 2px 0 0; color: var(--texto-2); }

.marca-icone {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--marca-clara), var(--marca));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marca-icone svg { width: 22px; height: 22px; }

.pergunta { font-size: 14px; font-weight: 600; margin: 0 0 12px; }

.escolhas { display: grid; gap: 10px; }

.escolha {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    background: var(--painel-2);
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
}

.escolha:hover { border-color: var(--marca); }
.escolha:active { transform: scale(.99); }

.escolha-titulo { font-weight: 600; font-size: 14.5px; }
.escolha-dica { font-size: 12.5px; color: var(--texto-2); }

.voltar {
    background: none;
    border: 0;
    color: var(--texto-2);
    font: inherit;
    font-size: 13px;
    padding: 0 0 12px;
    cursor: pointer;
}

.campo { display: block; margin-bottom: 14px; }

.campo > span {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--texto-2);
    margin-bottom: 5px;
}

.campo em { font-style: normal; font-weight: 400; }

input, textarea {
    width: 100%;
    font: inherit;
    color: var(--texto);
    background: var(--painel-2);
    border: 1px solid var(--borda);
    border-radius: 10px;
    padding: 10px 12px;
    outline: 0;
}

input:focus, textarea:focus {
    border-color: var(--marca);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .18);
}

#campo-documento { letter-spacing: .02em; font-variant-numeric: tabular-nums; }

.botao {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 12px;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--marca-clara), var(--marca));
    cursor: pointer;
}

.botao:disabled { opacity: .6; cursor: default; }

.botao-claro {
    background: var(--painel-2);
    color: var(--texto);
    border: 1px solid var(--borda);
    font-weight: 600;
    padding: 9px;
}

.alerta {
    background: var(--perigo-fundo);
    color: var(--perigo);
    font-size: 13px;
    border-radius: 10px;
    padding: 9px 12px;
    margin: 0 0 14px;
}

.rodape-legal {
    font-size: 11.5px;
    color: var(--texto-2);
    text-align: center;
    max-width: 420px;
    margin: 0;
}

/* ---------- chat ---------- */

.tela-chat {
    display: grid;
    grid-template-columns: 290px 1fr;
    height: 100dvh;
}

.lateral {
    background: var(--painel);
    border-right: 1px solid var(--borda);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.lateral-topo { display: flex; align-items: center; gap: 8px; }

.marca-compacta { flex: 1; min-width: 0; }

.lateral-nome {
    margin: 0;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lateral-sub {
    margin: 0;
    font-size: 12px;
    color: var(--texto-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lateral-rotulo {
    margin: 4px 0 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--texto-2);
}

.lista-conversas {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-conversa {
    width: 100%;
    text-align: left;
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 10px;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.item-conversa:hover { background: var(--painel-2); }

.item-conversa[aria-current="true"] {
    background: var(--painel-2);
    border-color: var(--borda);
}

.item-linha { display: flex; align-items: center; gap: 6px; }

.item-titulo {
    font-size: 13.5px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-previa {
    font-size: 12px;
    color: var(--texto-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.pino {
    background: var(--marca);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.conversa {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--painel-2);
}

.conversa-topo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--painel);
    border-bottom: 1px solid var(--borda);
}

.conversa-topo h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversa-estado {
    margin: 0;
    font-size: 12px;
    color: var(--texto-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selo {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--painel-2);
    color: var(--texto-2);
    border: 1px solid var(--borda);
    white-space: nowrap;
}

.selo.aberta { background: rgba(16, 185, 129, .14); color: #047857; border-color: transparent; }
.selo.espera { background: rgba(245, 158, 11, .16); color: #b45309; border-color: transparent; }

@media (prefers-color-scheme: dark) {
    .selo.aberta { color: #6ee7b7; }
    .selo.espera { color: #fcd34d; }
}

.icone {
    background: none;
    border: 0;
    color: var(--texto-2);
    padding: 7px;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
}

.icone:hover { background: var(--painel-2); color: var(--texto); }
.icone svg { width: 19px; height: 19px; }

.mensagens {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overscroll-behavior: contain;
}

.grupo { display: flex; flex-direction: column; max-width: min(620px, 82%); }
.grupo.eu { align-self: flex-end; align-items: flex-end; }
.grupo.eles { align-self: flex-start; }

.bolha {
    padding: 9px 13px;
    border-radius: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14.5px;
    box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
}

.eu .bolha {
    background: linear-gradient(135deg, var(--marca-clara), var(--marca));
    color: #fff;
    border-bottom-right-radius: 5px;
}

.eles .bolha {
    background: var(--bolha-op);
    border: 1px solid var(--borda);
    border-bottom-left-radius: 5px;
}

.assinatura { font-size: 11px; color: var(--texto-2); margin: 3px 4px 0; }

.sistema {
    align-self: center;
    background: var(--bolha-op);
    border: 1px solid var(--borda);
    color: var(--texto-2);
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 999px;
    text-align: center;
    max-width: 90%;
}

.anexo {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 7px;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, .08);
    font-size: 12.5px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border: 0;
    font-family: inherit;
    width: 100%;
    text-align: left;
}

.eu .anexo { background: rgba(255, 255, 255, .2); }
.anexo svg { width: 15px; height: 15px; flex: 0 0 15px; }
.anexo-nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anexo-tam { opacity: .75; font-size: 11.5px; }

.vazio {
    margin: auto;
    text-align: center;
    color: var(--texto-2);
    font-size: 13.5px;
    max-width: 320px;
}

.digitando {
    margin: 0;
    padding: 0 18px 8px;
    font-size: 12.5px;
    color: var(--texto-2);
    font-style: italic;
}

.csat {
    background: var(--painel);
    border-top: 1px solid var(--borda);
    padding: 12px 16px;
    text-align: center;
}

.csat p { margin: 0 0 6px; font-size: 13px; color: var(--texto-2); }

.estrela {
    background: none;
    border: 0;
    font-size: 25px;
    line-height: 1;
    color: #cbd5e1;
    cursor: pointer;
    padding: 0 2px;
}

.estrela.on { color: #f59e0b; }

.compositor {
    background: var(--painel);
    border-top: 1px solid var(--borda);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}

.compositor .alerta { margin-bottom: 8px; }

.linha { display: flex; align-items: flex-end; gap: 6px; }

#campo-mensagem {
    flex: 1;
    resize: none;
    max-height: 140px;
    border-radius: 12px;
}

.enviar {
    border: 0;
    border-radius: 12px;
    padding: 10px;
    background: linear-gradient(135deg, var(--marca-clara), var(--marca));
    color: #fff;
    cursor: pointer;
    display: inline-flex;
}

.enviar:disabled { opacity: .5; cursor: default; }
.enviar svg { width: 19px; height: 19px; }

.anexos-escolhidos { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }

.ficha {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--painel-2);
    border: 1px solid var(--borda);
    color: var(--texto-2);
    font-size: 11.5px;
    padding: 3px 8px;
    border-radius: 8px;
}

.so-mobile { display: none; }

/* ---------- mobile ---------- */

@media (max-width: 760px) {
    .tela-chat { grid-template-columns: 1fr; }

    .lateral {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(300px, 84vw);
        z-index: 20;
        transform: translateX(-102%);
        transition: transform .2s ease;
        box-shadow: var(--sombra);
    }

    .lateral.aberta { transform: none; }

    .so-mobile { display: inline-flex; }

    .grupo { max-width: 88%; }
}
