/* ── My Agent WP — Chat Widget ──────────────────────────────────────── */

:root {
    --maw-color: #2563eb; /* sobrescrito via wp_head com a cor configurada */
    --maw-radius: 16px;
    --maw-shadow: 0 8px 32px rgba(0,0,0,.18);
    --maw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Widget container ────────────────────────────────────────────────── */

#maw-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--maw-font);
    font-size: 15px;
    line-height: 1.5;
}

/* ── Bubble button ───────────────────────────────────────────────────── */

.maw-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--maw-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--maw-shadow);
    transition: transform .2s, box-shadow .2s;
    outline: none;
    margin-left: auto;
}

.maw-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 36px rgba(0,0,0,.24);
}

.maw-bubble:focus-visible {
    outline: 3px solid var(--maw-color);
    outline-offset: 3px;
}

.maw-bubble-icon {
    width: 26px;
    height: 26px;
    color: #fff;
    flex-shrink: 0;
    transition: opacity .15s, transform .15s;
}

.maw-icon-close { display: none; }

.maw-widget.is-open .maw-icon-open  { display: none; }
.maw-widget.is-open .maw-icon-close { display: block; }

/* ── Chat panel ─────────────────────────────────────────────────────── */

.maw-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: var(--maw-radius);
    box-shadow: var(--maw-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: mawPanelIn .2s ease;
}

.maw-panel[hidden] { display: none; }

@keyframes mawPanelIn {
    from { opacity: 0; transform: scale(.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}

/* ── Header ─────────────────────────────────────────────────────────── */

.maw-panel-header {
    background: var(--maw-color);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.maw-agent-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}

.maw-agent-dot {
    width: 9px;
    height: 9px;
    background: #4ade80;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,.4);
}

.maw-agent-name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.maw-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    color: rgba(255,255,255,.85);
    border-radius: 6px;
    transition: background .15s, color .15s;
}

.maw-close-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

.maw-close-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Header actions (concluir + fechar) ─────────────────────────────── */

.maw-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.maw-finish-btn {
    /* Nasce escondido: o JS só adiciona .is-visible depois de uma troca
       válida — pergunta do visitante + resposta do agente. */
    display: none;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,.16);
    border: none;
    cursor: pointer;
    color: #fff;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--maw-font);
    line-height: 1;
    transition: background .15s, opacity .15s;
}

.maw-finish-btn.is-visible {
    display: flex;
    animation: mawFinishIn .25s ease;
}

@keyframes mawFinishIn {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: none; }
}

.maw-finish-btn:hover { background: rgba(255,255,255,.28); }

.maw-finish-btn:disabled { opacity: .5; cursor: default; }

.maw-finish-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

@media (max-width: 420px) {
    .maw-finish-label { display: none; }
    .maw-finish-btn { padding: 6px; border-radius: 50%; }
}

/* ── Rating card (avaliação por estrelas) ───────────────────────────── */

.maw-rating-card {
    align-self: center;
    width: 100%;
    max-width: 260px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px 16px;
    text-align: center;
    animation: mawPanelIn .2s ease;
}

.maw-rating-prompt {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.maw-rating {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.maw-star {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: #d1d5db;
    line-height: 0;
    transition: color .12s, transform .1s;
}

.maw-star svg {
    width: 30px;
    height: 30px;
}

.maw-star:hover { transform: scale(1.12); }

.maw-star.is-filled { color: #f59e0b; }

.maw-star:disabled { cursor: default; }

.maw-star:disabled:hover { transform: none; }

.maw-rating-card.is-done .maw-rating { display: none; }

/* ── Messages area ───────────────────────────────────────────────────── */

.maw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.maw-messages::-webkit-scrollbar { width: 4px; }
.maw-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Message bubbles ─────────────────────────────────────────────────── */

.maw-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.maw-msg--agent {
    background: #f3f4f6;
    color: #111827;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.maw-msg--user {
    background: var(--maw-color);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────────────── */

.maw-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.maw-typing span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    display: inline-block;
    animation: mawDot 1.2s infinite ease-in-out;
}

.maw-typing span:nth-child(2) { animation-delay: .2s; }
.maw-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes mawDot {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-5px); }
}

/* ── Input area ─────────────────────────────────────────────────────── */

.maw-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.maw-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 9px 12px;
    font-family: var(--maw-font);
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 96px;
    overflow-y: auto;
    transition: border-color .15s;
}

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

.maw-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--maw-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: opacity .15s, transform .1s;
}

.maw-send-btn:hover   { opacity: .88; }
.maw-send-btn:active  { transform: scale(.94); }
.maw-send-btn:disabled { opacity: .45; cursor: default; }

.maw-send-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 420px) {
    #maw-widget {
        bottom: 16px;
        right: 16px;
    }

    .maw-panel {
        width: calc(100vw - 32px);
        right: 0;
    }
}
