body.flow-chat-overlay-open {
    overflow: hidden;
}

.icon.chat-overlay-trigger {
    cursor: pointer;
    position: relative;
    z-index: 3; /* Higher than the card's stretched-link (z-index: 1) */
}

.icon.chat-overlay-trigger.has-conversation i {
    color: #1d9e75;
}

.icon.chat-overlay-trigger.no-conversation i {
    color: #ffffff;
    -webkit-text-stroke: 1px #b4b2a9;
    text-stroke: 1px #b4b2a9;
}

.flow-chat-overlay-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 42, 0.34);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.flow-chat-overlay-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.flow-chat-overlay {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1205;
    display: flex;
    flex-direction: column;
    width: min(560px, 100vw);
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid #dbe3ee;
    box-shadow: -16px 0 38px rgba(15, 23, 42, 0.18);
    transform: translateX(102%);
    transition: transform 0.24s ease, width 0.24s ease;
}

.flow-chat-overlay.is-open {
    transform: translateX(0);
}

/* Com o painel da Isa aberto, o overlay fica mais largo pra caber os dois lado a lado */
body:not(.isa-panel-collapsed) .flow-chat-overlay.is-open {
    width: min(950px, 100vw);
}

.flow-chat-overlay-close {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 4;
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}

.flow-chat-overlay-close:hover {
    color: #1f2937;
}

.flow-chat-overlay-row {
    flex: 1;
    min-height: 0;
    display: flex;
}

.flow-chat-overlay-body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
}

/* #flow-messages-isa-panel já tem sua própria largura/estilo em flow-messages-isa-panel.css */
#flow-chat-overlay #flow-messages-isa-panel {
    height: auto;
}

/*
 * O painel é mais estreito que a área de chat da página cheia do Flow
 * Messages, então o rodapé de envio precisa se comportar como no breakpoint
 * mobile daquela página (itens empilham em vez de ficar numa linha só).
 */
#flow-chat-overlay .chat-input-row.chat-input-row-compact {
    display: flex;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
}

#flow-chat-overlay .chat-recipient-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

#flow-chat-overlay .chat-recipient-select {
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
}

#flow-chat-overlay .flow-message-quick-replies-wrapper,
#flow-chat-overlay #add-chat-participant,
#flow-chat-overlay .chat-emoji-wrapper,
#flow-chat-overlay .chat-message-audio-dictation-button,
#flow-chat-overlay .chat-message-audio-send-button,
#flow-chat-overlay .chat-send-button {
    flex: 0 0 auto;
}

#flow-chat-overlay .message-textarea-wrapper {
    flex: 1 1 auto;
    min-width: 0;
}

#flow-chat-overlay .message-textarea-wrapper textarea {
    width: 100%;
    min-width: 0;
}

#flow-chat-overlay .chat-send-button,
#flow-chat-overlay #add-chat-participant,
#flow-chat-overlay .chat-footer-action-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#flow-chat-overlay .chat-send-button {
    font-size: 0;
}

#flow-chat-overlay .chat-send-button::after {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    content: '\f1d8';
    font-size: 16px;
}

#flow-chat-overlay .chat-message-audio-dictation-button {
    color: #2563eb !important;
}

#flow-chat-overlay .chat-message-audio-dictation-button i,
#flow-chat-overlay .chat-message-audio-dictation-button .fas {
    color: #2563eb !important;
}

#flow-chat-overlay .chat-message-audio-dictation-button.is-recording {
    width: auto;
    min-width: 82px;
    color: #ffffff !important;
    border-color: #dc3545;
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

#flow-chat-overlay .chat-message-audio-dictation-button.is-recording i,
#flow-chat-overlay .chat-message-audio-dictation-button.is-recording .fas {
    color: #ffffff !important;
}

#flow-chat-overlay .chat-message-audio-send-button {
    border-color: #dbe4ef !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    color: #0f766e !important;
}

#flow-chat-overlay .chat-message-audio-send-button i,
#flow-chat-overlay .chat-message-audio-send-button .fas {
    color: #0f766e !important;
}

#flow-chat-overlay .chat-message-audio-send-button.is-recording,
#flow-chat-overlay .chat-message-audio-send-button.is-sending {
    width: auto;
    min-width: 82px;
    color: #ffffff !important;
    border-color: #dc2626 !important;
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%) !important;
}

#flow-chat-overlay .chat-message-audio-send-button.is-sending {
    border-color: #0d9488 !important;
    background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%) !important;
}

#flow-chat-overlay .chat-message-audio-send-button.is-recording i,
#flow-chat-overlay .chat-message-audio-send-button.is-recording .fas,
#flow-chat-overlay .chat-message-audio-send-button.is-sending i,
#flow-chat-overlay .chat-message-audio-send-button.is-sending .fas {
    color: #ffffff !important;
}

#flow-chat-overlay .chat-audio-send-preview {
    order: 4;
    width: 100%;
}

#flow-chat-overlay .chat-audio-send-preview-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #ccfbf1;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
}

#flow-chat-overlay .chat-audio-send-preview-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #0f766e;
    font-size: 12px;
    font-weight: 700;
}

#flow-chat-overlay .chat-audio-send-preview audio {
    flex: 1 1 auto;
    min-width: 160px;
    height: 34px;
}

#flow-chat-overlay .chat-audio-send-preview-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/*
 * Botões do cabeçalho (Isa / Finalizar / Ver detalhes), no mesmo visual do
 * Flow Messages (flow-messages-header-actions.css é escopado pra
 * #flow-messages-chat, que não existe aqui — replica só o essencial).
 */
#flow-chat-overlay .chat-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

#flow-chat-overlay .chat-header-modern-button,
#flow-chat-overlay .chat-header-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 34px;
    padding: 6px 11px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    box-shadow: 0 6px 14px rgba(148, 163, 184, 0.14);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

#flow-chat-overlay .chat-header-modern-button:hover,
#flow-chat-overlay .chat-header-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

#flow-chat-overlay .chat-header-actions .btn-outline-primary,
#flow-chat-overlay .chat-header-isa-button {
    color: #1d4ed8;
    border-color: #bfdbfe;
    background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}

#flow-chat-overlay .chat-header-actions .btn-outline-primary:hover,
#flow-chat-overlay .chat-header-isa-button:hover,
#flow-chat-overlay .chat-header-isa-button.is-active {
    color: #ffffff;
    border-color: #2563eb;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

#flow-chat-overlay .chat-header-actions .btn-outline-warning {
    color: #92400e;
    border-color: #fde68a;
    background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

#flow-chat-overlay .chat-header-actions .btn-outline-warning:hover {
    color: #78350f;
    border-color: #fbbf24;
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}

#flow-chat-overlay .chat-header-actions .btn-success,
#flow-chat-overlay .chat-header-actions .btn-outline-success {
    color: #047857;
    border-color: #a7f3d0;
    background: linear-gradient(180deg, #ffffff 0%, #ecfdf5 100%);
}

#flow-chat-overlay .chat-header-actions .btn-success:hover,
#flow-chat-overlay .chat-header-actions .btn-outline-success:hover {
    color: #ffffff;
    border-color: #059669;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

#flow-chat-overlay .chat-header-actions .btn-outline-secondary {
    color: #475569;
    border-color: #dbe4ef;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

#flow-chat-overlay .chat-header-actions .btn-outline-secondary:hover {
    color: #334155;
    border-color: #cbd5e1;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

/*
 * Responder mensagem: botão aparece só ao passar o mouse na bolha
 * (.message-bubble já tem position:relative em flow-whatsapp.css) e a
 * citação (.message-reply, estilo herdado de flow-ui.css) fica clicável
 * pra pular até a mensagem original.
 */
#flow-chat-overlay .message-reply-trigger {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: #475569;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

#flow-chat-overlay .message-item:hover .message-reply-trigger {
    display: flex;
}

#flow-chat-overlay .message-in .message-reply-trigger {
    right: auto;
    left: 4px;
}

#flow-chat-overlay .message-reply-trigger:hover {
    background: #ffffff;
    color: #1d4ed8;
}

#flow-chat-overlay .message-reply {
    cursor: pointer;
}

#flow-chat-overlay .reply-preview-bar {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    margin-bottom: 6px;
    border-left: 3px solid #2563eb;
    background: #eff6ff;
    border-radius: 6px;
}

#flow-chat-overlay .reply-preview-content {
    flex: 1 1 auto;
    min-width: 0;
}

#flow-chat-overlay .reply-preview-author {
    font-weight: 700;
    font-size: 11px;
    color: #1d4ed8;
}

#flow-chat-overlay .reply-preview-text {
    font-size: 12px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#flow-chat-overlay .reply-preview-cancel {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}

#flow-chat-overlay .reply-preview-cancel:hover {
    color: #1f2937;
}
