/* ── GEO KB Widget ──────────────────────────────────────────────────────── */
#oktoply-ai-widget {
    --oktoplyai-color: #f7194e;
    --oktoplyai-radius: 16px;
    --oktoplyai-shadow: 0 8px 32px rgba(0,0,0,.18);
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Botão flutuante */
#oktoplyai-toggle {
    width: 68px; height: 68px;
    border-radius: 50%;
    background: var(--oktoplyai-color);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--oktoplyai-shadow);
    transition: transform .2s, box-shadow .2s;
    color: #fff;
    outline: none;
    padding: 0;
    overflow: hidden;
    position: relative;
}
#oktoplyai-toggle:hover { transform: scale(1.08); box-shadow: 0 12px 36px rgba(0,0,0,.22); }

/* Spans que envolvem os ícones */
#oktoplyai-icon-open,
#oktoplyai-icon-close {
    width: 68px; height: 68px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    pointer-events: none;
}

/* SVG dentro dos spans */
#oktoplyai-icon-open svg,
#oktoplyai-icon-close svg {
    width: 32px; height: 32px;
    pointer-events: none;
}

/* Foto dentro do span open */
#oktoplyai-icon-open img {
    width: 68px; height: 68px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    display: block;
    pointer-events: none;
}

/* Quando há foto, fundo transparente */
#oktoplyai-toggle:has(#oktoplyai-icon-open img) {
    background: transparent;
    box-shadow: 0 4px 16px rgba(0,0,0,.22);
}
/* Ícone close sobre foto: usa a cor do botão configurada */
#oktoplyai-toggle:has(#oktoplyai-icon-open img) #oktoplyai-icon-close {
    background: var(--oktoplyai-color);
}

/* Painel do chat */
#oktoplyai-panel {
    position: absolute;
    bottom: 68px; right: 0;
    width: 360px;
    background: #fff;
    border-radius: var(--oktoplyai-radius);
    box-shadow: var(--oktoplyai-shadow);
    display: flex; flex-direction: column;
    overflow: hidden;
    max-height: 520px;
    transform-origin: bottom right;
    transform: scale(.92) translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
}
#oktoplyai-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}
@media (max-width: 420px) {
    #oktoplyai-panel { width: calc(100vw - 32px); right: 0; }
}

/* Header */
#oktoplyai-header {
    background: var(--oktoplyai-color);
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
#oktoplyai-header-info { display: flex; align-items: center; gap: 10px; }
#oktoplyai-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
#oktoplyai-name { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.2; }
#oktoplyai-status { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
#oktoplyai-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80; display: inline-block;
    animation: oktoplyai-pulse 2s infinite;
}
@keyframes oktoplyai-pulse {
    0%,100% { opacity: 1; } 50% { opacity: .5; }
}
#oktoplyai-status-text { font-size: 11px; color: rgba(255,255,255,.8); }
#oktoplyai-minimize {
    background: none; border: none; cursor: pointer; color: rgba(255,255,255,.7);
    padding: 4px; border-radius: 4px; line-height: 1;
    transition: color .15s;
}
#oktoplyai-minimize:hover { color: #fff; }
#oktoplyai-minimize svg { width: 18px; height: 18px; display: block; }

/* Mensagens */
#oktoplyai-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    scroll-behavior: smooth;
}
#oktoplyai-messages::-webkit-scrollbar { width: 4px; }
#oktoplyai-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.oktoplyai-msg {
    display: flex; gap: 8px; max-width: 88%;
    animation: oktoplyai-fadein .2s ease;
}
@keyframes oktoplyai-fadein { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.oktoplyai-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.oktoplyai-msg.bot  { align-self: flex-start; }

.oktoplyai-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--oktoplyai-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    flex-shrink: 0; margin-top: 2px;
}
.oktoplyai-msg.user .oktoplyai-msg-avatar { background: #e5e7eb; color: #555; }

.oktoplyai-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px; line-height: 1.55;
    white-space: pre-wrap; word-break: break-word;
}
.oktoplyai-msg.bot  .oktoplyai-msg-bubble { background: #f4f4f5; color: #1a1a1a; border-bottom-left-radius: 4px; }
.oktoplyai-msg.user .oktoplyai-msg-bubble { background: var(--oktoplyai-color); color: #fff; border-bottom-right-radius: 4px; }

/* Typing indicator */
.oktoplyai-typing .oktoplyai-msg-bubble {
    display: flex; align-items: center; gap: 4px; padding: 12px 14px;
}
.oktoplyai-typing span {
    width: 6px; height: 6px; border-radius: 50%; background: #aaa;
    animation: oktoplyai-bounce .8s infinite;
}
.oktoplyai-typing span:nth-child(2) { animation-delay: .15s; }
.oktoplyai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes oktoplyai-bounce {
    0%,80%,100% { transform: translateY(0); } 40% { transform: translateY(-5px); }
}

/* Input */
#oktoplyai-footer {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
}
#oktoplyai-input {
    flex: 1; resize: none; border: 1px solid #e5e7eb;
    border-radius: 20px; padding: 8px 14px;
    font-size: 13.5px; line-height: 1.4; outline: none;
    font-family: inherit; max-height: 96px; overflow-y: auto;
    transition: border-color .15s;
    /* Esconder scrollbar mantendo scroll funcional */
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* IE/Edge legacy */
}
#oktoplyai-input::-webkit-scrollbar { display: none; } /* Chrome/Safari/Edge */
#oktoplyai-input:focus { border-color: var(--oktoplyai-color); }
/* Remover spinners de number/tel inputs (alguns temas adicionam via CSS) */
#oktoply-ai-widget input[type="number"],
#oktoply-ai-widget input[type="tel"],
#oktoply-ai-widget input[type="text"],
#oktoply-ai-widget input[type="email"],
#oktoply-ai-widget textarea {
    -moz-appearance: textfield;
    appearance: none;
}
#oktoply-ai-widget input::-webkit-outer-spin-button,
#oktoply-ai-widget input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
#oktoplyai-send {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    background: var(--oktoplyai-color); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; transition: transform .15s, opacity .15s;
    padding: 0;
}
#oktoplyai-send:hover { transform: scale(1.08); }
#oktoplyai-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
#oktoplyai-send svg { width: 20px; height: 20px; display: block; }

#oktoplyai-wa-icon {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    background: #25D366; border: none; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    color: #fff; transition: transform .15s, opacity .15s;
    padding: 0; margin-left: 6px;
}
#oktoplyai-wa-icon:hover { transform: scale(1.08); }
#oktoplyai-wa-icon svg { width: 20px; height: 20px; display: block; }


/* Markdown no chat */
.oktoplyai-msg-bubble strong { font-weight: 700; }
.oktoplyai-msg-bubble em     { font-style: italic; }
.oktoplyai-msg-bubble code   {
    background: rgba(0,0,0,.08); border-radius: 3px;
    padding: 1px 5px; font-size: 12px; font-family: monospace;
}
.oktoplyai-msg.user .oktoplyai-msg-bubble code { background: rgba(255,255,255,.2); }

/* Links nas mensagens */
.oktoplyai-msg.bot .oktoplyai-msg-bubble a {
    color: var(--oktoplyai-color);
    text-decoration: underline;
    word-break: break-all;
}
.oktoplyai-msg.bot .oktoplyai-msg-bubble a:hover { opacity: .8; }
.oktoplyai-msg.user .oktoplyai-msg-bubble a {
    color: #fff;
    text-decoration: underline;
    word-break: break-all;
}

/* Lead form */
#oktoplyai-lead-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
}
#oktoplyai-lead-intro {
    font-size: 13px;
    color: #444;
    margin: 0;
    line-height: 1.5;
}
#oktoplyai-lead-form input {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
#oktoplyai-lead-form input:focus { border-color: var(--oktoplyai-color); }
#oktoplyai-lead-actions {
    display: flex;
    gap: 8px;
}
#oktoplyai-lead-submit {
    flex: 1;
    background: var(--oktoplyai-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
#oktoplyai-lead-submit:hover { opacity: .88; }
#oktoplyai-lead-skip {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    transition: color .15s;
}
#oktoplyai-lead-skip:hover { color: #333; }



/* ── Pill CTA Button ─────────────────────────────────────────────────────── */
#oktoplyai-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    outline: none;
    transition: transform .2s;
}
#oktoplyai-pill:hover { transform: scale(1.04); }

/* Foto PNG solta acima — sem recorte, sem borda, fundo transparente */
#oktoplyai-pill-avatar {
    width: 140px;
    height: auto;
    display: block;
    pointer-events: none;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,.25));
    margin-bottom: 0px;
    position: relative;
    z-index: 2;
}

/* Badge pill embaixo */
#oktoplyai-pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--oktoplyai-pill-color, rgba(20,20,20,0.82));
    border: 2px solid var(--oktoplyai-pill-border, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 50px;
    padding: 8px 18px;
    pointer-events: none;
    box-shadow: 0 2px 14px rgba(0,0,0,.3);
    position: relative;
    z-index: 1;
}

/* Ponto verde pulsante */
#oktoplyai-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    animation: oktoplyai-pulse 2s infinite;
}

/* Texto */
#oktoplyai-pill-text {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .5px;
    white-space: nowrap;
}

/* Visibilidade */
#oktoply-ai-widget.open #oktoplyai-pill { display: none; }
#oktoply-ai-widget.pill-mode #oktoplyai-toggle { display: none; }
#oktoply-ai-widget:not(.pill-mode) #oktoplyai-pill { display: none; }

/* ── Mobile adjustments ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #oktoply-ai-widget {
        bottom: 20px !important;
    }
    #oktoplyai-pill-avatar {
        width: 80px;
    }
    #oktoplyai-pill-badge {
        padding: 7px 14px;
        gap: 6px;
    }
    #oktoplyai-pill-text {
        font-size: 12px;
    }
    #oktoplyai-pill-dot {
        width: 7px;
        height: 7px;
    }
}


/* ── Phone field with country picker ────────────────────────────────────── */
#oktoplyai-phone-container { position: relative; }

.oktoplyai-phone-wrap {
    display: flex;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: visible;
    background: #fff;
    transition: border-color .15s;
    margin-bottom: 0;
}
.oktoplyai-phone-wrap:focus-within { border-color: var(--oktoplyai-color); }

.oktoplyai-phone-country {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: #f8f9fa;
    border-right: 1px solid #e5e7eb;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    color: #444;
    min-width: 76px;
    user-select: none;
}
.oktoplyai-phone-country:hover { background: #f0f0f0; }
.oktoplyai-phone-flag { font-size: 16px; line-height: 1; }
.oktoplyai-phone-ddi  { font-size: 12px; font-weight: 500; }
.oktoplyai-phone-arrow { font-size: 9px; color: #999; }

.oktoplyai-phone-number {
    flex: 1;
    border: none !important;
    border-radius: 0 8px 8px 0 !important;
    padding: 9px 10px !important;
    font-size: 14px !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    min-width: 0;
}

.oktoplyai-phone-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    width: 260px;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    z-index: 99999;
    display: none;
}
.oktoplyai-phone-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    color: #202124;
}
.oktoplyai-phone-dropdown-item:hover  { background: #f4f4f5; }
.oktoplyai-phone-dropdown-item.selected { background: #e8f0fe; font-weight: 500; }
.oktoplyai-phone-dropdown-item span:last-child { color: #888; margin-left: auto; }

/* ── Lead Chat phone footer ──────────────────────────────────────────────── */
#oktoplyai-footer-phone {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}
#oktoplyai-footer-phone .oktoplyai-phone-wrap {
    flex: 1;
    margin-bottom: 0;
}
#oktoplyai-lc-phone-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--oktoplyai-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    transition: opacity .15s;
}
#oktoplyai-lc-phone-send svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
#oktoplyai-lc-phone-send:hover { opacity: .88; }

/* ── WhatsApp CTA button ─────────────────────────────────────────────────── */
.oktoplyai-whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: #fff !important;
    text-decoration: none !important;
    padding: 9px 16px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s, transform .1s;
    white-space: nowrap;
}
.oktoplyai-whatsapp-btn:hover {
    background: #1ebe5d;
    transform: scale(1.03);
}
.oktoplyai-whatsapp-btn svg {
    flex-shrink: 0;
}

/* ── Green dot overlapping round toggle button (half in, half out) ─────── */
#oktoplyai-toggle-green-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #22c55e;
    border-radius: 50%;
    box-sizing: border-box;
    pointer-events: none;
    animation: oktoplyai-pulse 2s infinite;
    z-index: 3;
}

/* Hide green dot when chat is open */
#oktoply-ai-widget.open #oktoplyai-toggle-green-dot {
    display: none;
}

/* Hide green dot in pill mode (pill has its own dot) */
#oktoply-ai-widget.pill-mode #oktoplyai-toggle-green-dot {
    display: none;
}

/* ── Invite balloon (round mode only) ───────── */
#oktoplyai-invite-balloon {
    position: absolute;
    bottom: 0;
    right: 84px; /* 68px toggle + 16px gap */
    max-width: 340px;
    min-width: 240px;
    height: 68px; /* same as button */
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
    padding: 0 32px 0 18px;
    animation: oktoplyai-balloon-in .35s cubic-bezier(.34,1.56,.64,1) both;
    pointer-events: auto;
    z-index: 9998;
}

/* Never show in pill mode */
#oktoply-ai-widget.pill-mode #oktoplyai-invite-balloon {
    display: none !important;
}

#oktoplyai-invite-balloon p {
    margin: 0;
    font-size: 14px;
    line-height: 1.35;
    color: #2d3748;
}
#oktoplyai-invite-balloon p strong { font-weight: 700; color: #1a202c; }

#oktoplyai-invite-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #cbd2d9;
    line-height: 1;
    padding: 2px 4px;
    transition: color .15s;
}
#oktoplyai-invite-close:hover { color: #718096; }

/* Hide balloon once widget is open */
#oktoply-ai-widget.open #oktoplyai-invite-balloon {
    display: none !important;
}

/* Initial hidden state (before 5s delay) */
#oktoplyai-invite-balloon.oktoplyai-invite-hidden {
    display: none;
}

@keyframes oktoplyai-balloon-in {
    from { opacity: 0; transform: translateX(16px) scale(.94); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* Mobile: stacked above button, narrower */
@media (max-width: 480px) {
    #oktoplyai-invite-balloon {
        bottom: 82px;
        right: 0;
        max-width: calc(100vw - 48px);
    }
}
