/* ══════════════════════════════════════════
   chatbot.css
   ══════════════════════════════════════════ */

/* ── RESET & VARIÁVEIS ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── OVERLAY — clique fora fecha (desktop/tablet) ── */
#chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9996;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: overlay-in .25s ease;
    cursor: pointer;
}

#chat-overlay.visible {
    display: block;
}

@keyframes overlay-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── LAUNCHER BUTTON ── */
#chat-launcher {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #25D366;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(24, 247, 24, 0.5);
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s;
    z-index: 9999;
    outline: none;
}

#chat-launcher.toast-visible {
    display: none;
}

#chat-launcher:hover {
    transform: scale(1.12) rotate(8deg);
    box-shadow: 0 8px 32px rgba(5, 148, 5, 0.5);

}

#chat-launcher svg {
    width: 28px;
    height: 28px;
}

#chat-launcher .icon-close {
    display: none;
}

#chat-launcher.open .icon-chat {
    display: none;
}

#chat-launcher.open .icon-close {
    display: block;
}

/* pulse ring */
#chat-launcher::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: var(--grad);
    opacity: .3;
    animation: pulse-ring 2.5s ease-out infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: .3;
    }

    70% {
        transform: scale(1.4);
        opacity: 0;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* notification badge */
#chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--c4);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-head);
    animation: badge-pop .4s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes badge-pop {
    from {
        transform: scale(0)
    }

    to {
        transform: scale(1)
    }
}

/* ── CHAT WINDOW ── */
#chat-window {
    position: fixed;
    bottom: 108px;
    right: 28px;
    width: var(--chat-w);
    height: var(--chat-h);
    background: var(--dark);
    border-radius: var(--radius);
    box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, .06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transform: scale(.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .35s cubic-bezier(.34, 1.36, .64, 1), opacity .25s ease;
    transform-origin: bottom right;
    max-height: calc(100vh - 120px);
}

#chat-window.visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── HEADER ── */
.chat-header {
    background: var(--green-rbr);
    padding: 18px 20px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    flex-shrink: 0;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, .15);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid rgba(255, 255, 255, .35);
    flex-shrink: 0;
    position: relative;
}

.avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c4);
    border: 2px solid var(--dark);
}

.header-info {
    flex: 1;
}

.header-name {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    letter-spacing: .3px;
}

.header-status {
    font-size: 11.5px;
    color: rgba(255, 255, 255, .75);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c4);
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1
    }

    50% {
        opacity: .4
    }
}

/* ── STEPS PROGRESS ── */
.steps-bar {
    display: flex;
    gap: 5px;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.step-dot {
    flex: 1;
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .1);
    transition: background .4s;
}

.step-dot.done {
    background: var(--primary-color);
}

/* ── MESSAGES AREA ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 4px;
}

/* ── MESSAGE BUBBLE ── */
.msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: msg-in .35s cubic-bezier(.34, 1.36, .64, 1);
}

@keyframes msg-in {
    from {
        transform: translateY(12px) scale(.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.msg.bot {
    align-self: flex-start;
}

.msg.user {
    align-self: flex-end;
}

.msg-bubble {
    padding: 11px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.msg.bot .msg-bubble {
    background: var(--bubble-bot);
    color: var(--text-light);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, .07);
}

.msg.user .msg-bubble {
    background: var(--bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.msg.user .msg-time {
    text-align: right;
}

/* ── TYPING INDICATOR ── */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: var(--bubble-bot);
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    animation: msg-in .35s ease;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: bounce-dot .9s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: .15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes bounce-dot {
    0%, 60%, 100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* ── QUICK REPLIES ── */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 6px;
    padding: 0 2px;
}

.qr-btn {
    padding: 7px 14px;
    border-radius: 20px;
    background: transparent;
    border: 1.5px solid #fff;
    color: var(--primary-color);
    font-size: 12.5px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all .2s;
    font-weight: 500;
}

.qr-btn:hover {
    background: rgba(58, 211, 104, 0.15);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* ── FORM FIELDS ── */
.chat-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    animation: msg-in .35s ease;
}

.chat-form-field input {
    background: rgba(255, 255, 255, .07);
    border: 1.5px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 13.5px;
    outline: none;
    transition: border-color .2s;
}

.chat-form-field input::placeholder {
    color: var(--text-muted);
}

.chat-form-field input:focus {
    border-color: var(--c1);
}

.chat-form-field .field-submit {
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--grad);
    border: none;
    color: #fff;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: opacity .2s, transform .2s;
    letter-spacing: .4px;
}

.chat-form-field .field-submit:hover {
    opacity: .88;
    transform: translateY(-1px);
}

/* ── INPUT AREA ── */
.chat-input-area {
    padding: 12px 14px 14px;
    background: rgba(255, 255, 255, .03);
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, .07);
    border: 1.5px solid rgba(255, 255, 255, .1);
    border-radius: 24px;
    padding: 10px 16px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 13.5px;
    outline: none;
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    transition: border-color .2s;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

#chat-input:focus {
    border-color: rgba(60, 216, 255, 0.5);
}

#send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--third-color);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .2s, box-shadow .2s;
    box-shadow: 0 4px 16px rgba(46, 139, 245, 0.35);
}

#send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(46, 139, 245, 0.35);
}

#send-btn svg {
    width: 18px;
    height: 18px;
}

/* ── CHAT FOOTER ── */
.chat-footer {
    padding: 6px 16px 10px;
    text-align: center;
    font-size: 10.5px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-footer a {
    color: var(--c5);
    text-decoration: none;
}

/* ── OVERLAY (fechar clicando fora — desktop/tablet) ── */
#chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9997;
}

#chat-overlay.visible {
    display: block;
}

/* ── NOTIFICATION TOAST ── */
#chat-toast {
    position: fixed;
    bottom: 104px;
    right: 28px;
    background: linear-gradient(135deg, #1a1a2e, #0f0f1a);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 14px;
    padding: 12px 18px 12px 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
    max-width: 300px;
    z-index: 9997;
    cursor: pointer;
    animation: toast-in .4s cubic-bezier(.34, 1.36, .64, 1);
}

@keyframes toast-in {
    from {
        transform: translateX(40px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

#chat-toast.hidden {
    display: none;
}

.toast-avatar {
    font-size: 22px;
}

.toast-name {
    font-family: var(--font-head);
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.toast-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── SUCCESS CARD ── */
.success-card {
    background: linear-gradient(135deg, rgba(0, 245, 160, .08), rgba(0, 217, 245, .08));
    border: 1px solid rgba(0, 245, 160, .25);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 6px;
    animation: msg-in .4s ease;
}

.success-card .success-icon {
    font-size: 26px;
    margin-bottom: 6px;
}

.success-card h4 {
    font-family: var(--font-head);
    font-size: 14px;
    color: var(--c4);
    margin-bottom: 4px;
}

.success-card p {
    font-size: 12.5px;
    color: var(--text-light);
    line-height: 1.5;
}

/* ── PRODUCT CARD ── */

.product-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.product-card {
    background: var(--bubble-bot);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: 6px;
    animation: msg-in .35s ease;
    cursor: pointer;
    transition: border-color .2s, transform .2s;
}

.product-card:hover {
    border-color: rgba(255, 60, 172, .4);
    transform: translateY(-2px);
}

.product-card-img {
    width: 100%;
    height: 120px;
    overflow: hidden;
}

.product-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-card-body {
    padding: 10px 12px 12px;
}

.product-card-name {
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.product-card-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.4;
}

.product-card-cta {
    margin-top: 8px;
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--grad);
    color: #fff;
    font-size: 11px;
    font-family: var(--font-head);
    font-weight: 700;
    letter-spacing: .3px;
}

/* ── OVERLAY (clique fora para fechar) ── */
#chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9990;
    background: transparent;
    cursor: default;
}

#chat-overlay.visible {
    display: block;
}

/* ══════════════════════════════════════════
   RESPONSIVO
   ══════════════════════════════════════════ */

/* ── Tablet (481px – 768px) ── */
@media (max-width: 768px) {
    :root {
        --chat-w: 360px;
        --chat-h: 560px;
    }

    #chat-window {
        right: 16px;
        bottom: 96px;
    }

    #chat-launcher {
        right: 20px;
        bottom: 20px;
    }

    #chat-toast {
        right: 16px;
        bottom: 96px;
        max-width: 260px;
    }
}

/* ── Mobile (até 480px) — fullscreen ── */
@media (max-width: 480px) {

    /* Overlay não faz sentido em fullscreen */
    #chat-overlay {
        display: none !important;
    }

    /* Janela: ocupa a tela inteira */
    #chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        /* fallback */
        height: 100dvh;
        /* exclui barra do browser móvel */
        max-height: none;
        border-radius: 0;
        transform-origin: bottom center;
        transform: translateY(100%);
        opacity: 0;
    }

    #chat-window.visible {
        transform: translateY(0);
        opacity: 1;
    }

    /* Respeita notch / status bar */
    .chat-header {
        padding-top: max(18px, env(safe-area-inset-top));
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .chat-messages {
        padding: 16px 14px 8px;
    }

    /* 16px evita zoom automático no iOS ao focar input */
    #chat-input {
        font-size: 16px;
    }

    .chat-form-field input {
        font-size: 16px;
    }

    /* Resposta rápida ocupa largura total */
    .qr-btn {
        flex: 1 1 auto;
        text-align: center;
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Safe-area inferior */
    .chat-input-area {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }

    .chat-footer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* Launcher: some quando chat está aberto em fullscreen */
    #chat-launcher {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
    }

    #chat-launcher.open {
        display: none;
    }

    /* Toast */
    #chat-toast {
        left: 12px;
        right: 12px;
        bottom: max(86px, calc(env(safe-area-inset-bottom) + 72px));
        max-width: 100%;
    }
}

/* ── Teclado virtual aberto (altura muito pequena) ── */
@media (max-height: 500px) and (max-width: 480px) {
    .steps-bar {
        display: none;
    }

    .chat-footer {
        display: none;
    }

    .chat-header {
        padding-top: 12px;
        padding-bottom: 10px;
    }

    .avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}


/* ── REPRESENTATIVE CARDS ── */
.rep-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.rep-card {
    background: var(--bubble-bot);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    animation: msg-in .35s ease;
    transition: border-color .2s;
}

.rep-card:hover {
    border-color: rgba(255, 60, 172, .4);
}

.rep-foto {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--grad);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rep-foto img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rep-foto-placeholder {
    font-size: 22px;
}

.rep-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.rep-nome {
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.rep-regiao {
    font-size: 11.5px;
    color: var(--text-muted);
}

.rep-whatsapp {
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(37, 211, 102, .15);
    border: 1px solid rgba(37, 211, 102, .3);
    color: #25D366;
    font-size: 11px;
    font-family: var(--font-head);
    font-weight: 700;
    text-decoration: none;
    transition: background .2s;
    width: fit-content;
}

.rep-whatsapp:hover {
    background: rgba(37, 211, 102, .25);
}

.lgpd-consent {
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lgpd-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.5;
    color: #555;
}

.lgpd-label input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: #4CAF50;
    flex-shrink: 0;
    cursor: pointer;
}

.lgpd-label a {
    color: #4CAF50;
    text-decoration: underline;
}