/**
 * Chat Leads Widget — Estilos
 * Mobile-first, responsivo e acessível
 */

:root {
    --chat-primary: #2d6a4f;
    --chat-primary-dark: #1b4332;
    --chat-bg: #ffffff;
    --chat-user-bg: #e8f5e9;
    --chat-bot-bg: #f5f5f5;
    --chat-shadow: 0 4px 20px rgba(0,0,0,0.15);
    --chat-radius: 12px;
}

/* ═══════════ BOTÃO DO CHAT ═══════════ */

.chat-widget-button {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--chat-primary);
    border-radius: 50%;
    box-shadow: var(--chat-shadow);
    cursor: pointer;
    z-index: 9997;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    background: var(--chat-primary-dark);
}

.chat-widget-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.chat-widget-button.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Badge de notificação */
.chat-widget-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ═══════════ JANELA DO CHAT ═══════════ */

.chat-widget-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header do chat */
.chat-widget-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    padding: 20px;
    border-radius: var(--chat-radius) var(--chat-radius) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-widget-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-widget-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-widget-header-text p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chat-widget-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-widget-close:hover {
    opacity: 1;
}

/* Corpo do chat (mensagens) */
.chat-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget-body::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* Mensagens */
.chat-message {
    display: flex;
    gap: 8px;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--chat-radius);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.bot .chat-message-content {
    background: var(--chat-bot-bg);
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.user .chat-message-content {
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Opções de botões */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chat-option-btn {
    background: white;
    border: 2px solid var(--chat-primary);
    color: var(--chat-primary);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.chat-option-btn:hover {
    background: var(--chat-primary);
    color: white;
}

/* Footer do chat (input) */
.chat-widget-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
    border-radius: 0 0 var(--chat-radius) var(--chat-radius);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-widget-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    background: white;
}

.chat-widget-input:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.chat-send-btn {
    background: var(--chat-primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--chat-primary-dark);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Loading indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* ═══════════ MOBILE ═══════════ */

@media (max-width: 768px) {
    .chat-widget-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
        bottom: 15px;
        right: 15px;
    }

    .chat-widget-button {
        width: 56px;
        height: 56px;
        bottom: 80px;
        right: 15px;
    }

    .chat-widget-button svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .chat-widget-header {
        padding: 16px;
    }

    .chat-widget-body {
        padding: 16px;
    }

    .chat-message-content {
        max-width: 80%;
        font-size: 13px;
    }
}
