/* --- Estilos do Chat --- */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.3);
        opacity: 1;
    }
}

.typing-dots div {
    animation: bounce 1.4s infinite ease-in-out;
}

/* --- Estilo para botão de gravação --- */
.recording-pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}


/* =========================================
 NOVOS ESTILOS WHATSAPP 
=========================================
*/

/* Fundo do Chat (área de mensagens) */
#chat-messages {
    background-image: url('../../images/fundo-chat.jpg');
    background-color: #E5DDD5;
    /* Fallback de cor */
    background-repeat: round;
}

/* Bolha de Mensagem Base */
.message-bubble {
    padding: 6px 10px;
    border-radius: 7.5px;
    max-width: 80%;
    /* Mais largo que o max-w-xs original */
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
    line-height: 1.4;
    position: relative;
    font-size: 0.95rem;
    /* Tamanho de fonte similar */
}

/* Bolha do Usuário (Enviada) */
.user-bubble {
    background-color: #DCF8C6;
    color: #303030;
    margin-right: 8px;
    /* Espaço para a "cauda" */
    border-radius: 7.5px 0 7.5px 7.5px;
    /* Canto superior direito reto */
}

/* "Cauda" da Bolha do Usuário */
.user-bubble::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    /* Posiciona a cauda para fora da bolha */
    width: 0;
    height: 0;
    border-style: solid;
    /* Cria um triângulo apontando para a direita */
    border-width: 0 0 10px 10px;
    border-color: transparent transparent transparent #DCF8C6;
}

/* Bolha do Bot (Recebida) */
.bot-bubble {
    background-color: #FFFFFF;
    color: #303030;
    margin-left: 8px;
    /* Espaço para a "cauda" */
    border-radius: 0 7.5px 7.5px 7.5px;
    /* Canto superior esquerdo reto */
}

/* "Cauda" da Bolha do Bot */
.bot-bubble::after {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    /* Posiciona a cauda para fora da bolha */
    width: 0;
    height: 0;
    border-style: solid;
    /* Cria um triângulo apontando para a esquerda */
    border-width: 0 10px 10px 0;
    border-color: transparent #FFFFFF transparent transparent;
}

/* Ajuste para imagens dentro das bolhas */
.message-bubble img {
    border-radius: 5px;
    /* Arredonda a imagem */
    display: block;
    width: 100%;
}

.message-bubble.user-bubble img {
    /* Imagens enviadas pelo usuário podem não ter padding */
    border: 2px solid #DCF8C6;
}

.message-bubble.bot-bubble img {
    border: 2px solid #FFFFFF;
}


/* Timestamp (ajuste de cor e margem) */
.message .text-xs {
    color: #8A9A9E !important;
    /* Cor cinza do WhatsApp */
    margin-top: 4px;
    opacity: 1 !important;
    /* Sempre visível (pode remover o group-hover no JS se preferir) */
}

.user-message .text-xs {
    text-align: right;
    margin-right: 10px;
    /* Alinha com a bolha */
}

.bot-message .text-xs {
    margin-left: 10px;
    /* Alinha com a bolha */
}


/* =========================================
 FIM DOS NOVOS ESTILOS WHATSAPP 
=========================================
*/


/* --- Estilos do Dock (Widget) --- */
.chat-dock-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
}

.chat-dock {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 160px;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
}

.dock-item {
    position: relative;
    cursor: pointer;
    margin: 0 2px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform, opacity, width, height;
}

.dock-item.contracting {
    transform: scale(0);
    opacity: 0;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    pointer-events: none;
}

.dock-item.selected {
    transform: scale(1.2);
    z-index: 10;
    cursor: pointer;
    margin-left: 0 !important;
    margin-right: 15px !important;
}

.dock-item img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    display: block;
    transition: all 0.3s ease;
}

.info-popup {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* pointer-events habilitado para permitir reabrir chat */
}

.info-popup strong {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.dock-item:hover .info-popup {
    opacity: 1;
    visibility: visible;
}

/* --- Estilos Responsivos para Mobile --- */
@media (max-width: 500px) {
    .chat-dock-container {
        width: 95vw;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
    }

    .chat-dock {
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .chat-dock::-webkit-scrollbar {
        display: none;
    }

    .dock-item {
        flex-shrink: 0;
    }

    /* Ajustes mobile para bolhas */
    .message-bubble {
        max-width: 85%;
    }
}

/* --- Estilos da Tela de Ligação "Chamando" --- */
@keyframes calling-pulse {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(0.95);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.calling-dot {
    animation: calling-pulse 1.4s infinite ease-in-out;
}

.calling-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.calling-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* --- Estilos da Interface de Ligação Ativa --- */
#call-interface-container {
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
}

/* As transcrições não são mais mostradas aqui, mas mantemos o estilo caso precisemos no futuro */
.call-transcript-bubble {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.call-transcript-bubble.user {
    background-color: #3b82f6;
    /* Azul */
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.call-transcript-bubble.bot {
    background-color: #4b5563;
    /* Cinza escuro */
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
}

/* =========================================
   RATING MODAL STYLES
   ========================================= */

/* Star rating styling */
.star-btn {
    cursor: pointer;
    transition: transform 0.15s ease, color 0.15s ease;
}

.star-btn:hover {
    transform: scale(1.15);
}

.star-btn.selected {
    color: #FBBF24 !important;
    /* Yellow-400 */
}

.star-btn.selected:hover {
    color: #F59E0B !important;
    /* Yellow-500 */
}

/* Modal animation */
#rating-modal {
    transform: scale(0.95);
    opacity: 0;
}

#rating-modal.show {
    transform: scale(1);
    opacity: 1;
}

/* Rating overlay fade in */
#rating-overlay.fade-in {
    animation: fadeInOverlay 0.3s ease forwards;
	z-index: 3000;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Thank you overlay animation */
#thank-you-overlay .bg-white {
    animation: bounceIn 0.4s ease;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =========================================
   ESTILOS PARA CONTEXTO DE IFRAME
   ========================================= */

/* Garante que o chat-container fique posicionado à direita */
#chat-container {
    left: auto !important;
    right: 16px !important;
	z-index: 2000;
}
/* Alinhamento do popup para o primeiro agente (esquerda) */
.dock-item:first-child .info-popup {
    left: 0;
    transform: translateX(0);
}

/* Alinhamento do popup para o ultimo agente (direita) */
.dock-item:last-child .info-popup {
    left: auto;
    right: 0;
    transform: translateX(0);
}

/* Alinhamento do popup para o agente selecionado (direita) */
.dock-item.selected .info-popup {
    left: auto;
    right: 0;
    transform: translateX(0);
}

/* Ocultar popup do agente quando o chat esta aberto */
.dock-container-chat-open .dock-item.selected .info-popup {
    display: none !important;
}
/* =========================================
   DOCK EMPILHADO (STACKED LAYOUT)
   ========================================= */

/* Container do dock */
.chat-dock {
    flex-direction: row !important;
    align-items: center !important;
    height: auto !important;
    padding-bottom: 10px;
    width: auto;
}

/* Itens do dock (agentes) */
.dock-item {
    margin: 0 !important;
    margin-left: -25px !important;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    transform: none !important;
}

.dock-item:first-child {
    margin-left: 0 !important;
}

/* Ajuste das imagens */
.dock-item img {
    width: 50px !important;
    height: 50px !important;
    border: 2px solid #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}
