/*
   Chat BB — Réplica Exata do Original
   Banco do Brasil - Atendimento Digital
   ============================================ */

:root {
    --bb-blue: #1653fd;
    --bb-dark-blue: #0d2745;
    --bb-light-blue: #dceefb;
    --bb-white: #ffffff;
    --bb-text: #212529;
    --bb-text-muted: rgba(0, 0, 0, 0.3);
    --bb-border: rgba(0, 0, 0, 0.12);
    --bb-protocol-bg: #ffffff;
    --bb-sent-bg: #f2f2f2;
    --bb-sender-yellow: #fdf429;
    --bb-input-bg: #ffffff;
    --bb-chat-bg: #ffffff;
    --bb-bubble-radius: 4px;
    --bb-font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================
   CONTAINER PRINCIPAL
   ============================================ */
.bb-chat-container {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 369px !important;
    height: 100% !important;
    background: var(--bb-white) !important;
    display: none;
    flex-direction: column !important;
    z-index: 2147483647 !important;
    font-family: var(--bb-font-family) !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1) !important;
    overflow: hidden !important;
}

.bb-chat-container.bb-chat-visible {
    display: flex !important;
}

/* Screens */
.bb-chat-screen {
    display: none !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow: hidden !important;
    position: relative !important;
}

.bb-chat-screen.bb-chat-screen--active {
    display: flex !important;
}

/* ============================================
   HEADER
   ============================================ */
.bb-chat-header {
    background: #1653fd !important; /* Azul original do BB */
    color: var(--bb-white) !important;
    padding: 0 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    height: 48px !important;
    flex-shrink: 0 !important;
}

.bb-chat-header__title {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.bb-chat-header__icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23fdf429"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H5.17L4 17.17V4h16v12z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.bb-chat-header__text {
    font-size: 16px !important;
    font-weight: 400 !important;
}

.bb-chat-header__actions {
    display: flex !important;
    align-items: center !important;
    gap: 20px !important;
}

.bb-chat-header__back, .bb-chat-header__close {
    cursor: pointer !important;
    user-select: none !important;
}

.bb-chat-header__back {
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.bb-chat-header__close {
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M19 13H5v-2h14v2z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* ============================================
   TABS
   ============================================ */
.bb-chat-tabs {
    display: flex !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    background: #ffffff !important;
}

.bb-chat-tabs__item {
    flex: 1 !important;
    text-align: center !important;
    padding: 15px 0 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--bb-text-muted) !important;
    cursor: pointer !important;
    position: relative !important;
}

.bb-chat-tabs__item--active {
    color: var(--bb-blue) !important;
}

.bb-chat-tabs__item--active::after {
    content: '' !important;
    position: absolute !important;
    bottom: -1px !important;
    left: 0 !important;
    width: 100% !important;
    height: 3px !important;
    background: var(--bb-blue) !important;
}

/* ============================================
   CONTENT AREAS
   ============================================ */
.bb-chat-tab-content {
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    text-align: center !important;
}

.bb-chat-empty__title {
    font-size: 16px !important;
    font-weight: 600 !important;
    margin-bottom: 10px !important;
}

.bb-chat-empty__subtitle {
    font-size: 14px !important;
    color: var(--bb-text-muted) !important;
}

/* ============================================
   FOOTER
   ============================================ */
.bb-chat-footer {
    padding: 15px 20px !important;
    border-top: 1px solid #f0f0f0 !important;
}

.bb-chat-btn-primary {
    width: 100% !important;
    padding: 18px 20px !important;
    border: none !important;
    border-radius: 0 !important;
    background: #eff3fe !important;
    color: #1653fd !important;
    font-weight: 500 !important;
    font-size: 15px !important;
    text-align: center !important;
    cursor: pointer !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.bb-chat-btn-primary::after {
    content: '' !important;
}

/* ============================================
   LISTA ATENDIMENTO
   ============================================ */
.bb-chat-atendimento-lista {
    padding: 20px 0 !important;
}

.bb-chat-atendimento__title {
    padding: 0 20px 15px !important;
    font-size: 18px !important;
    font-weight: 600 !important;
}

.bb-chat-atendimento__item {
    display: flex !important;
    justify-content: space-between !important;
    padding: 15px 20px !important;
    border-bottom: 1px solid #f5f5f5 !important;
    cursor: pointer !important;
    font-size: 15px !important;
    transition: background-color 0.2s ease !important;
    align-items: center !important;
    width: 100% !important;
}

.bb-chat-atendimento__item:hover {
    background-color: #f9f9f9 !important;
}

/* ============================================
   CONVERSA HEADER (PROTOCOLO)
   ============================================ */
.bb-chat-conversa-header {
    background: var(--bb-white) !important;
    padding: 12px 20px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: flex-start !important;
    flex-shrink: 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
}

.bb-chat-conversa-header__info {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    width: 100%;
    position: relative;
}

.bb-chat-conversa__title {
    font-weight: 400 !important;
    font-size: 18px !important;
    display: block !important;
    color: #212529 !important;
    margin-bottom: 8px !important;
}

.bb-chat-conversa__protocolo-label {
    font-size: 13px !important;
    color: #212529 !important;
    display: block !important;
    margin-bottom: 2px !important;
}

.bb-chat-conversa__protocolo-wrapper {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
}

.bb-chat-conversa__protocolo-num {
    font-weight: 400 !important;
    font-size: 18px !important;
    display: block !important;
    color: #212529 !important;
    letter-spacing: 0.2px !important;
}

.bb-chat-conversa__copy {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: #eff3fe !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-20%) !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%231653fd"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 22px !important;
    z-index: 10 !important;
}

.bb-chat-conversa__copy:active {
    background-color: #dceefb !important;
}

/* ============================================
   MENSAGENS
   ============================================ */
.bb-chat-conversa__messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 15px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    min-height: 0 !important;
    background-color: #ffffff !important;
}

.bb-msg-row {
    display: flex !important;
    gap: 8px !important;
    max-width: 90% !important;
    align-items: flex-start;
}

.bb-msg-row.sent {
    align-self: flex-end !important;
    flex-direction: row-reverse !important;
}

.bb-avatar {
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}

.bb-avatar img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.bb-msg-content {
    display: flex !important;
    flex-direction: column !important;
    width: auto !important;
    max-width: 100% !important;
}

.bb-msg-sender {
    font-size: 15px !important;
    color: #fdf429 !important;
    font-weight: 500 !important;
    margin-bottom: 8px !important;
    display: block !important;
}

.bb-msg-bubble {
    padding: 8px 12px !important;
    border-radius: 8px !important;
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    position: relative !important;
    word-wrap: break-word;
    box-shadow: 0 2px 3px rgba(0, 0, 0, .07) !important;
    border: 1px solid rgba(0, 0, 0, .12) !important;
    min-width: 60px !important;
    max-width: 100% !important;
    width: fit-content !important;
}

.bb-msg-row.sent .bb-msg-bubble {
    align-self: flex-end !important;
}

.bb-msg-row.received .bb-msg-bubble {
    align-self: flex-start !important;
}

.bb-msg-bubble.received {
    background: var(--bb-blue) !important;
    color: #ffffff !important;
}

.bb-msg-bubble.sent {
    background: #f8f8f8 !important; /* Cinza mais claro conforme solicitado */
    color: #333333 !important;
}

.bb-msg-text {
    margin-bottom: 4px !important;
    white-space: pre-wrap !important;
}

.bb-reply-box {
    background: #e8e8e8 !important;
    padding: 8px 12px !important;
    margin-bottom: 8px !important;
    border-radius: 8px !important;
    text-align: left !important;
    font-size: 13px !important;
}

.bb-reply-box-label {
    color: #3354fd !important;
    font-weight: bold !important;
    margin-bottom: 2px !important;
    font-size: 11px !important;
    display: block !important;
}

.bb-reply-box-text {
    color: #666 !important;
    word-break: break-word !important;
    display: block !important;
}

.bb-msg-time {
    font-size: 11px !important;
    margin-top: 4px !important;
    text-align: right !important;
    opacity: 0.9 !important;
    color: inherit;
}

/* ============================================
   INPUT AREA — CORRIGIDO: DENTRO DA CAIXA
   ============================================ */
.bb-chat-input-area {
    padding: 8px 16px !important;
    border-top: 1px solid #eee !important;
    flex-shrink: 0 !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
}

#chatInput {
    width: 100% !important;
    padding: 12px 0 !important;
    border: none !important;
    outline: none !important;
    font-size: 16px !important;
    color: #333 !important;
    background: transparent !important;
    font-family: var(--bb-font-family) !important;
}

#chatInput::placeholder {
    color: #999 !important;
}

.bb-chat-input-actions {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 4px 0 8px 0 !important;
}

.bb-chat-input-actions__left {
    display: flex !important;
    gap: 16px !important;
}

#btnEmoji, #btnAttach {
    width: 24px !important;
    height: 24px !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    border: none !important;
    background-color: transparent !important;
    cursor: pointer !important;
    padding: 0 !important;
}

#btnEmoji {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23666666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M8 14s1.5 2 4 2 4-2 4-2"></path><line x1="9" y1="9" x2="9.01" y2="9"></line><line x1="15" y1="9" x2="15.01" y2="9"></line></svg>') !important;
}

#btnAttach {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23666666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>') !important;
}

#btnSend {
    background: #eff3fe !important;
    color: #1653fd !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    padding: 6px 16px !important;
    border-radius: 2px !important;
    border: none !important;
    cursor: pointer !important;
}

/* ============================================
   EMOJI PICKER
   ============================================ */
.bb-emoji-picker {
    position: absolute !important;
    bottom: 100% !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 280px !important;
    height: 180px !important;
    background: white !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    padding: 10px !important;
    display: none;
    flex-wrap: wrap !important;
    overflow-y: auto !important;
    gap: 5px !important;
    z-index: 2147483647 !important;
    margin-bottom: 5px !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2); /* Sombra para destacar */
}

.bb-emoji-item {
    cursor: pointer !important;
    font-size: 20px !important;
}

/* ============================================
   CHAT ENCERRADO
   ============================================ */
#chatInput:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

#btnSend:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

/* Estilo para o indicador de digitação */
.bb-typing-indicator {
    font-size: 12px;
    color: var(--bb-text-muted);
    margin-top: 5px;
    margin-left: 5px;
    font-style: italic;
}

/* ============================================
   MESSAGE OPTIONS MENU — 3 pontinhos fora da bolha
   ============================================ */
.bb-msg-bubble {
    position: relative !important;
}

/* Container dos 3 pontinhos fica ao lado da bolha */
.bb-msg-options-container {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
}

.bb-msg-options-btn {
    background: none !important;
    border: none !important;
    color: #999 !important;
    cursor: pointer !important;
    font-size: 18px !important;
    padding: 0 4px !important;
    opacity: 1 !important; /* FIXO: Sempre visivel */
    display: flex !important;
    align-items: center !important;
    line-height: 1 !important;
    transition: color 0.2s !important;
    visibility: visible !important;
}

.bb-msg-options-btn:hover {
    color: #3354fd !important;
}

.bb-msg-menu {
    position: absolute !important;
    top: 28px !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    min-width: 130px !important;
    z-index: 1000 !important;
    overflow: hidden !important;
    border: 1px solid #eee !important;
}

/* Menu sempre abre para a direita (padrão BB) */
.bb-msg-menu {
    right: 0 !important;
    left: auto !important;
}

.bb-msg-menu-item {
    padding: 10px 15px !important;
    font-size: 13px !important;
    color: #333 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    transition: background 0.2s !important;
}

.bb-msg-menu-item:hover {
    background: #f5f5f5 !important;
}

.bb-msg-menu-icon {
    width: 16px !important;
    height: 16px !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    display: inline-block !important;
}

.bb-msg-menu-icon.reply {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23666"><path d="M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z"/></svg>') !important;
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
}

.bb-msg-menu-icon.copy {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23666"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>') !important;
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
}

/* Ajuste para o seletor de emojis não ficar cortado */
.bb-chat-input-area {
    position: relative !important;
}

/* ============================================
   AJUSTES PARA MÚLTIPLOS ATENDIMENTOS
   ============================================ */
.bb-chat-tab-pane {
    display: none !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
}

.bb-chat-tab-pane--active {
    display: flex !important;
}

.bb-chat-lista-atendimentos {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    text-align: left !important;
}

.bb-chat-atendimento__item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    padding: 15px 20px !important;
    background: #ffffff !important;
    border-bottom: 1px solid #f5f5f5 !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
}

.bb-chat-atendimento__item:hover {
    background-color: #f9f9f9 !important;
}

.bb-chat-tab-content {
    padding: 16px !important;
    display: block !important;
    overflow-y: auto !important;
}

.bb-chat-empty {
    padding: 40px 20px !important;
    text-align: center !important;
}

/* Estilos para a Tela de Seleção */
.bb-chat-selecao-item {
    transition: background-color 0.1s ease !important;
}

.bb-chat-selecao-item:active {
    background-color: #f9f9f9 !important;
}
