:root {
    color-scheme: dark;
    --bg: #050807;
    --panel: #08130f;
    --panel-2: #0d1d18;
    --bubble-in: #172722;
    --bubble-out: #006b53;
    --line: rgba(255, 255, 255, .08);
    --green: #22d27f;
    --green-dark: #087a50;
    --green-soft: #0d3024;
    --text: #f5faf8;
    --muted: #9eb3ab;
    --danger: #ff7b7b;
    --shadow: 0 25px 80px rgba(0, 0, 0, .48);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at 50% 0%, #13372b 0, transparent 38%),
        var(--bg);
    color: var(--text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body {
    min-height: 100vh;
}

button,
input {
    font: inherit;
}

.app-shell {
    width: min(100%, 560px);
    height: 100vh;
    min-height: 0;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(6, 17, 13, .98);
    box-shadow: var(--shadow);
}

.chat-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 78px;
    padding: 13px 15px;
    border-bottom: 1px solid var(--line);
    background: rgba(6, 17, 13, .96);
    backdrop-filter: blur(14px);
}

.avatar {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 2px solid var(--green);
    border-radius: 50%;
    background: linear-gradient(145deg, #263e36, #0c1814);
    color: var(--green);
    font-size: 21px;
    font-weight: 900;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-copy {
    min-width: 0;
    flex: 1;
}

.header-copy strong {
    display: block;
    overflow: hidden;
    color: #fff;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-copy span {
    display: block;
    margin-top: 4px;
    color: var(--green);
    font-size: 12px;
}

.header-badge {
    padding: 7px 9px;
    border: 1px solid var(--green-dark);
    border-radius: 999px;
    color: var(--green);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .04em;
    white-space: nowrap;
}

.chat-scroll {
    flex: 1;
    min-height: 0;
    padding: 18px 14px;
    overflow-y: auto;
    background:
        radial-gradient(
            circle at 1px 1px,
            rgba(255, 255, 255, .035) 1px,
            transparent 0
        );
    background-size: 18px 18px;
}

.message-row {
    display: flex;
    margin: 0 0 11px;
}

.message-row.out {
    justify-content: flex-end;
}

.message {
    width: fit-content;
    max-width: 90%;
    padding: 12px 13px 8px;
    border-radius: 7px 16px 16px;
    background: var(--bubble-in);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-line;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.message-row.out .message {
    border-radius: 16px 7px 16px 16px;
    background: var(--bubble-out);
}

.message-time {
    display: block;
    margin-top: 7px;
    color: rgba(255, 255, 255, .58);
    font-size: 10px;
    text-align: right;
}

.typing {
    display: inline-flex;
    gap: 5px;
    padding: 14px 16px;
    border-radius: 7px 16px 16px;
    background: var(--bubble-in);
}

.typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: typing 1s infinite ease-in-out;
}

.typing i:nth-child(2) {
    animation-delay: .16s;
}

.typing i:nth-child(3) {
    animation-delay: .32s;
}

@keyframes typing {
    0%,
    100% {
        opacity: .35;
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.actions-panel {
    position: relative;
    z-index: 25;
    width: 100%;
    max-height: 52vh;
    flex: 0 0 auto;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
    overflow-y: auto;
    border-top: 1px solid var(--line);
    background: rgba(7, 20, 16, .98);
    backdrop-filter: blur(18px);
}

.actions-title {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.action-grid {
    display: grid;
    gap: 8px;
}

.action-button {
    width: 100%;
    min-height: 50px;
    padding: 11px 14px;
    border: 1px solid var(--green-dark);
    border-radius: 17px;
    background: #0d2b22;
    color: #fff;
    font-weight: 750;
    line-height: 1.25;
    cursor: pointer;
    transition:
        transform .12s ease,
        border-color .12s ease,
        background .12s ease;
}

.action-button:hover,
.action-button:focus-visible {
    border-color: var(--green);
    outline: none;
    transform: translateY(-1px);
}

.action-button.primary {
    border-color: var(--green);
    background: #124d37;
}

.action-button.support {
    border-color: #295546;
    background: #0a1f18;
}

.action-button.back {
    color: var(--muted);
}

.action-button.link {
    border-color: var(--green);
}

.input-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--green-dark);
    border-radius: 16px;
    background: #0a1d16;
}

.input-card input {
    width: 100%;
    min-height: 50px;
    padding: 12px 13px;
    border: 1px solid #315b4d;
    border-radius: 13px;
    outline: none;
    background: #071510;
    color: #fff;
    font-size: 16px;
}

.input-card input:focus {
    border-color: var(--green);
}

.input-consent {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

.system-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
}

@media (min-width: 561px) {
    body {
        padding: 18px;
    }

    .app-shell {
        height: calc(100vh - 36px);
        min-height: 0;
        border: 1px solid rgba(34, 210, 127, .2);
        border-radius: 22px;
        overflow: hidden;
    }

    .actions-panel {
        border-radius: 0 0 22px 22px;
    }
}


/* V4 — imagens de orientação dentro da conversa */

.chat-media-group {
    display: grid;
    gap: 10px;
    margin: 4px 0 14px;
}

.chat-media-card {
    overflow: hidden;
    border: 1px solid rgba(34, 210, 127, .25);
    border-radius: 15px;
    background: #0b1d17;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}

.chat-media-image {
    display: block;
    width: 100%;
    max-height: 290px;
    object-fit: contain;
    background: #050807;
}

.chat-media-copy {
    padding: 10px 12px 12px;
}

.chat-media-copy strong {
    display: block;
    color: #fff;
    font-size: 13px;
    line-height: 1.35;
}

.chat-media-copy span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}

.chat-code-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--green-dark);
    border-radius: 14px;
    background: #0b251c;
}

.chat-code-card span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.chat-code-card strong {
    color: var(--green);
    font-size: 24px;
    letter-spacing: .06em;
}

@media (max-width: 420px) {
    .chat-media-image {
        max-height: 230px;
    }
}

/* V5 — resultado profissional do teste */

.test-result-card {
    display: grid;
    gap: 9px;
    margin: 4px 0 15px;
    padding: 14px;
    border: 1px solid rgba(34, 210, 127, .46);
    border-radius: 17px;
    background:
        linear-gradient(
            145deg,
            rgba(15, 58, 43, .96),
            rgba(7, 29, 22, .98)
        );
    box-shadow: 0 15px 36px rgba(0, 0, 0, .3);
}

.test-result-title {
    padding-bottom: 9px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    color: var(--green);
    font-size: 15px;
    font-weight: 850;
}

.test-result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.test-result-copy {
    min-width: 0;
}

.test-result-copy span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.test-result-copy strong {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
    color: #fff;
    font-size: 15px;
}

.copy-button {
    flex: 0 0 auto;
    min-width: 70px;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid var(--green);
    border-radius: 11px;
    background: rgba(34, 210, 127, .13);
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.test-result-note {
    padding-top: 5px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}
/* V5.3 — fluxo natural e correção mobile */

html,
body {
    height: 100%;
    min-height: 100%;
}

body {
    min-height: 100dvh;
}

.app-shell {
    height: 100dvh;
    max-height: 100dvh;
}

.typing-wrap {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border-radius: 7px 16px 16px;
    background: var(--bubble-in);
}

.typing-wrap > span {
    color: var(--muted);
    font-size: 11px;
    font-style: italic;
}

.typing-wrap .typing {
    padding: 0;
    background: transparent;
}

.actions-panel {
    max-height: 43dvh;
    padding:
        9px 12px
        calc(9px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
}

.actions-title {
    margin-bottom: 7px;
    font-size: 10px;
}

.action-grid {
    gap: 6px;
}

.action-button {
    min-height: 42px;
    padding: 9px 11px;
    border-radius: 13px;
    font-size: 14px;
    line-height: 1.2;
}

.action-button.support {
    min-height: 39px;
    font-size: 13px;
}

.chat-scroll {
    padding: 13px 12px;
    overscroll-behavior: contain;
}

.message {
    max-width: 88%;
    padding: 10px 11px 7px;
    font-size: 14px;
    line-height: 1.45;
}

.chat-media-group {
    margin-bottom: 10px;
}

.chat-media-image {
    max-height: 235px;
}

.chat-media-copy {
    padding: 8px 10px 10px;
}

.system-note {
    display: none !important;
}

@media (max-width: 420px) {
    .chat-header {
        min-height: 68px;
        padding: 9px 11px;
    }

    .avatar {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .header-copy strong {
        font-size: 15px;
    }

    .header-badge {
        padding: 6px 7px;
        font-size: 8px;
    }

    .actions-panel {
        max-height: 41dvh;
    }

    .action-button {
        min-height: 40px;
        font-size: 13px;
    }

    .chat-media-image {
        max-height: 210px;
    }
}

@supports (-webkit-touch-callout: none) {
    .app-shell {
        height: 100dvh;
        max-height: 100dvh;
    }

    .actions-panel {
        padding-bottom:
            calc(10px + env(safe-area-inset-bottom));
    }
}

/* V5.4 — Logo administrável */

.site-brand-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-brand-logo img {
    display: block;
    width: auto;
    max-width: 92px;
    height: 32px;
    object-fit: contain;
}

@media (max-width: 420px) {
    .site-brand-logo img {
        max-width: 70px;
        height: 26px;
    }
}

/*
 * KZY_H12845_FLY_REVENDEDOR
 *
 * O flyer de revenda é vertical e precisa utilizar toda
 * a largura disponível do chat.
 *
 * Esta regra NÃO altera Downloader, código 208385,
 * XCloudTV ou qualquer outra imagem do atendimento.
 */
.chat-media-image[src*="assets/img/revenda/kzytv-revendedor.jpg"] {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    object-position: top center;
    margin: 0 auto;
}

/*
 * No flyer de revenda, o cartão também ocupa toda
 * a largura disponível da conversa.
 */
.chat-media-card:has(
    .chat-media-image[src*="assets/img/revenda/kzytv-revendedor.jpg"]
) {
    width: 100%;
    max-width: 100%;
}

/*
 * Mobile:
 * mantém 100% da largura disponível e deixa a altura
 * natural do flyer, para que o conteúdo fique legível.
 */
@media (max-width: 560px) {
    .chat-media-image[src*="assets/img/revenda/kzytv-revendedor.jpg"] {
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: none;
    }
}
