/* =============================================================
   chat-widget.css — Widget de atendimento JBD
============================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Fraunces:ital,wght@0,600;1,400&display=swap');

/* ── Botão flutuante ── */
#jbd-chat-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a3a5c 0%, #2d6a4f 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(26,58,92,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

#jbd-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(26,58,92,0.45);
}

#jbd-chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: opacity 0.2s ease;
}

#jbd-chat-toggle .icon-close { display: none; }
#jbd-chat-toggle.aberto .icon-chat  { display: none; }
#jbd-chat-toggle.aberto .icon-close { display: block; }

/* Badge de notificação */
#jbd-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: #e63946;
    border-radius: 50%;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#jbd-chat-badge.visivel {
    opacity: 1;
    transform: scale(1);
}

/* ── Janela do chat ── */
#jbd-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9999;
    width: 360px;
    max-height: 520px;
    background: #f8f7f4;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
}

#jbd-chat-window.aberto {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ── */
#jbd-chat-header {
    background: linear-gradient(135deg, #1a3a5c 0%, #2d6a4f 100%);
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.jbd-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Fraunces', serif;
    font-size: 18px;
    color: #fff;
    font-style: italic;
}

.jbd-header-info {
    flex: 1;
}

.jbd-header-nome {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    line-height: 1.2;
}

.jbd-header-status {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.jbd-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #52b788;
    animation: pulsar 2s ease infinite;
}

@keyframes pulsar {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Mensagens ── */
#jbd-chat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#jbd-chat-msgs::-webkit-scrollbar { width: 4px; }
#jbd-chat-msgs::-webkit-scrollbar-track { background: transparent; }
#jbd-chat-msgs::-webkit-scrollbar-thumb { background: #d0cfc9; border-radius: 4px; }

.jbd-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    line-height: 1.5;
    animation: entrar 0.2s ease;
}

@keyframes entrar {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.jbd-msg.bot {
    background: #fff;
    color: #1c1c1c;
    border-radius: 4px 16px 16px 16px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.jbd-msg.user {
    background: linear-gradient(135deg, #1a3a5c, #2d6a4f);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    align-self: flex-end;
}

.jbd-msg.bot .jbd-link {
    color: #2d6a4f;
    text-decoration: underline;
    word-break: break-all;
}

.jbd-msg.bot .jbd-link:hover {
    color: #1a3a5c;
}

/* Typing indicator */
.jbd-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 4px 16px 16px 16px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    animation: entrar 0.2s ease;
}

.jbd-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1a3a5c;
    opacity: 0.4;
    animation: digitar 1.2s ease infinite;
}

.jbd-typing span:nth-child(2) { animation-delay: 0.2s; }
.jbd-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes digitar {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50%       { opacity: 1;   transform: translateY(-4px); }
}

/* Botão WhatsApp */
.jbd-btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    padding: 8px 14px;
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.jbd-btn-whatsapp:hover { background: #1ebe59; }

.jbd-btn-whatsapp svg {
    width: 15px;
    height: 15px;
    fill: #fff;
    flex-shrink: 0;
}

/* ── Tela de identificação ── */
#jbd-chat-identificacao {
    padding: 14px 14px 16px;
    background: #fff;
    border-top: 1px solid #ece9e3;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.jbd-id-titulo {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: #666;
    margin: 0 0 2px;
}

#jbd-chat-identificacao input {
    border: 1.5px solid #e0ddd7;
    border-radius: 10px;
    padding: 9px 13px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    color: #1c1c1c;
    background: #f8f7f4;
    outline: none;
    transition: border-color 0.2s;
}

#jbd-chat-identificacao input:focus { border-color: #1a3a5c; }
#jbd-chat-identificacao input::placeholder { color: #aaa; }

#jbd-id-confirmar {
    background: linear-gradient(135deg, #1a3a5c, #2d6a4f);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 2px;
}

#jbd-id-confirmar:hover { opacity: 0.9; }

/* ── Input area ── */
#jbd-chat-footer {
    padding: 12px 14px 14px;
    background: #fff;
    border-top: 1px solid #ece9e3;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

#jbd-chat-input {
    flex: 1;
    border: 1.5px solid #e0ddd7;
    border-radius: 12px;
    padding: 9px 13px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    color: #1c1c1c;
    background: #f8f7f4;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 80px;
    transition: border-color 0.2s;
}

#jbd-chat-input:focus { border-color: #1a3a5c; }
#jbd-chat-input::placeholder { color: #aaa; }

#jbd-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a3a5c, #2d6a4f);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s;
}

#jbd-chat-send:hover  { transform: scale(1.08); }
#jbd-chat-send:active { transform: scale(0.95); }
#jbd-chat-send:disabled { opacity: 0.4; cursor: default; transform: none; }

#jbd-chat-send svg {
    width: 17px;
    height: 17px;
    fill: #fff;
    margin-left: 2px;
}

/* Rodapé discreto */
#jbd-chat-credito {
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    color: #bbb;
    padding: 0 14px 10px;
    background: #fff;
    flex-shrink: 0;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    #jbd-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
    }

    #jbd-chat-toggle {
        bottom: 20px;
        right: 20px;
    }
}
