/* ============================================================
   Sousa Comunicação — Chatbot UI v2.0
   Estilo: painel lateral direito, altura total (inspirado Banpará)
   Cores: verde #213A28 | ouro #B88400 | creme #F5F0DC
   ============================================================ */

/* ── Reset base ── */
#sousa-chat-toggle,
#sousa-chat-window,
#sousa-chat-window * {
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
}

/* ────────────────────────────────────────────────
   BOTÃO FLUTUANTE — robô GIF
   Aparece quando o chat está fechado.
   Some (scale 0) quando o painel abre.
──────────────────────────────────────────────── */
#sousa-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    width: 110px;
    height: 110px;
    border-radius: 0;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    filter: drop-shadow(0 5px 16px rgba(0,0,0,0.38));
    transition:
        transform 0.30s ease,
        filter 0.30s ease,
        width 0.30s ease,
        height 0.30s ease,
        opacity 0.25s ease;
    outline: none;
}

#sousa-chat-toggle:hover,
#sousa-chat-toggle:focus-visible {
    transform: translateY(-4px) scale(1.05);
    filter: drop-shadow(0 10px 22px rgba(0,0,0,0.42));
}

/* Quando o painel está aberto: some completamente */
#sousa-chat-toggle.sousa-chat-toggle--active {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
    width: 110px;
    height: 110px;
}

.schat-toggle-gif {
    width: 100%;
    height: 100%;
    border-radius: 0;
    display: block;
    object-fit: contain;
}

/* ────────────────────────────────────────────────
   PAINEL DO CHAT — lateral direita, altura total
──────────────────────────────────────────────── */
#sousa-chat-window {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    z-index: 9997;
    background: #fff;
    box-shadow: -6px 0 40px rgba(0,0,0,0.22), -1px 0 8px rgba(0,0,0,0.10);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(420px);
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.30s ease,
        transform 0.30s ease;
}

#sousa-chat-window.sousa-chat--open {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* ── Header ── */
#sousa-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px 18px 20px;
    background: linear-gradient(135deg, #213A28 0%, #2f5439 100%);
    color: #fff;
    flex-shrink: 0;
}

.schat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 22px;
    line-height: 1;
}

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

.schat-agent-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schat-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    margin-top: 3px;
}

.schat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5EE090;
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(94,224,144,0.6);
    animation: schat-pulse 2.2s infinite;
}

@keyframes schat-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(94,224,144,0.6); }
    60%  { box-shadow: 0 0 0 6px rgba(94,224,144,0); }
    100% { box-shadow: 0 0 0 0 rgba(94,224,144,0); }
}

#sousa-chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: none;
    cursor: pointer;
    color: #fff;
    transition: background 0.18s ease;
    flex-shrink: 0;
    outline: none;
    padding: 0;
}

#sousa-chat-close:hover,
#sousa-chat-close:focus-visible {
    background: rgba(255,255,255,0.28);
}

#sousa-chat-close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ── Área de mensagens ── */
#sousa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #F9F8F5;
    scroll-behavior: smooth;
}

#sousa-chat-messages::-webkit-scrollbar {
    width: 5px;
}

#sousa-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#sousa-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(33,58,40,0.20);
    border-radius: 4px;
}

/* ── Bubbles ── */
.schat-msg {
    display: flex;
    max-width: 88%;
}

.schat-msg--bot {
    align-self: flex-start;
}

.schat-msg--user {
    align-self: flex-end;
}

.schat-bubble {
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.schat-msg--bot .schat-bubble {
    background: #fff;
    color: #1a1a1a;
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.schat-msg--user .schat-bubble {
    background: #213A28;
    color: #fff;
    border-radius: 18px 4px 18px 18px;
}

/* ── Indicador de digitação ── */
#sousa-chat-typing {
    display: none;
    align-self: flex-start;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin: 0 0 2px 0;
}

.schat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #213A28;
    opacity: 0.35;
    animation: schat-bounce 1.2s infinite;
}

.schat-dot:nth-child(2) { animation-delay: 0.18s; }
.schat-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes schat-bounce {
    0%, 80%, 100% { transform: translateY(0);    opacity: 0.35; }
    40%            { transform: translateY(-6px); opacity: 0.85; }
}

/* ── Opções / quick-replies ── */
#sousa-chat-options {
    padding: 10px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    background: #F9F8F5;
    border-top: 1px solid rgba(33,58,40,0.07);
    flex-shrink: 0;
    max-height: 240px;
    overflow-y: auto;
}

#sousa-chat-options:empty {
    padding: 0;
    border-top: none;
}

#sousa-chat-options::-webkit-scrollbar {
    width: 3px;
}

#sousa-chat-options::-webkit-scrollbar-thumb {
    background: rgba(33,58,40,0.15);
    border-radius: 3px;
}

.schat-opt {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: 1.5px solid rgba(33,58,40,0.22);
    border-radius: 10px;
    background: #fff;
    color: #213A28;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        transform 0.14s ease;
    outline: none;
    line-height: 1.4;
}

.schat-opt:hover,
.schat-opt:focus-visible {
    background: #213A28;
    border-color: #213A28;
    color: #fff;
    transform: translateX(3px);
}

/* ── Branding strip ── */
.schat-footer {
    padding: 7px 16px;
    background: #fff;
    border-top: 1px solid rgba(33,58,40,0.08);
    text-align: center;
    font-size: 11px;
    color: rgba(33,58,40,0.45);
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.schat-footer a {
    color: rgba(33,58,40,0.55);
    text-decoration: none;
}

.schat-footer a:hover {
    color: #213A28;
}

/* ── Área de input livre ── */
.schat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border-top: 1px solid rgba(33,58,40,0.1);
    flex-shrink: 0;
}

.schat-restart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(33,58,40,0.07);
    border: none;
    cursor: pointer;
    color: #213A28;
    flex-shrink: 0;
    transition: background 0.18s ease;
    outline: none;
    padding: 0;
}

.schat-restart-btn:hover,
.schat-restart-btn:focus-visible {
    background: rgba(33,58,40,0.16);
}

.schat-restart-btn svg {
    width: 16px;
    height: 16px;
}

#sousa-chat-input {
    flex: 1;
    height: 40px;
    padding: 0 14px;
    border: 1.5px solid rgba(33,58,40,0.2);
    border-radius: 20px;
    font-size: 14px;
    color: #1a1a1a;
    background: #f9f8f5;
    outline: none;
    transition: border-color 0.18s ease;
    font-family: inherit;
}

#sousa-chat-input:focus {
    border-color: #213A28;
    background: #fff;
}

#sousa-chat-input::placeholder {
    color: rgba(33,58,40,0.38);
}

#sousa-chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #213A28;
    border: none;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
    transition: background 0.18s ease, transform 0.14s ease;
    outline: none;
    padding: 0;
}

#sousa-chat-send:hover,
#sousa-chat-send:focus-visible {
    background: #2f5439;
    transform: scale(1.08);
}

#sousa-chat-send svg {
    width: 16px;
    height: 16px;
}

/* ── WordPress admin bar: empurra o painel 32px para baixo ── */
.admin-bar #sousa-chat-window {
    top: 32px;
}

/* ── Oculta botão flutuante enquanto o menu mobile está aberto ── */
body.menu-is-open #sousa-chat-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

/* ────────────────────────────────────────────────
   RESPONSIVO — mobile: botão acima do WhatsApp
──────────────────────────────────────────────── */
@media (max-width: 680px) {
    #sousa-chat-toggle {
        width: 82px;
        height: 82px;
        bottom: 90px;
        right: 16px;
        border-radius: 50%;
        background: var(--color-primary, #213A28);
        border: 3px solid rgba(184,132,0,0.5);
    }

    #sousa-chat-toggle.sousa-chat-toggle--active {
        width: 82px;
        height: 82px;
    }

    .schat-toggle-gif {
        border-radius: 50%;
        object-fit: cover;
    }
}

/* ────────────────────────────────────────────────
   RESPONSIVO — mobile (≤480px): tela cheia
──────────────────────────────────────────────── */
@media (max-width: 480px) {
    #sousa-chat-toggle {
        width: 74px;
        height: 74px;
        bottom: 90px;
        right: 16px;
        border-radius: 50%;
        background: var(--color-primary, #213A28);
        border: 3px solid rgba(184,132,0,0.5);
    }

    #sousa-chat-window {
        top: 0;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        height: 100svh;
        transform: translateY(100%);
        box-shadow: 0 -6px 30px rgba(0,0,0,0.20);
    }

    #sousa-chat-window.sousa-chat--open {
        transform: translateY(0);
    }

    #sousa-chat-options {
        max-height: 42%;
    }
}
