/* Chat Widget Flutuante - Totalmente Responsivo */

/* ========================================
   CONTAINER
======================================== */
#chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========================================
   BOTÃO DO CHAT
======================================== */
#chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

#chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#chat-widget-button svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* Badge de notificação */
#chat-widget-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: none;
    align-items: center;
    justify-content: center;
}

/* ========================================
   JANELA DO CHAT - DESKTOP
======================================== */
#chat-widget-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#chat-widget-window.open {
    display: flex;
}

/* ========================================
   HEADER DO CHAT
======================================== */
#chat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    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;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

#chat-widget-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

#chat-widget-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 2px 0 0 0;
    line-height: 1.2;
}

#chat-widget-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

#chat-widget-close:hover {
    opacity: 1;
}

/* ========================================
   CORPO DO CHAT
======================================== */
#chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f5f5f5;
}

.chat-widget-message {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-widget-message.user {
    justify-content: flex-end;
}

.chat-widget-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.chat-widget-message.assistant .chat-widget-message-content {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px 12px 12px 4px;
}

.chat-widget-message.user .chat-widget-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 4px 12px;
}

.chat-widget-message.assistant .chat-widget-message-content a {
    color: #667eea;
    text-decoration: underline;
    font-weight: 500;
    word-break: break-all;
}

.chat-widget-message.assistant .chat-widget-message-content strong {
    color: #333;
    font-weight: 600;
}

/* ========================================
   TYPING INDICATOR
======================================== */
.chat-widget-typing {
    display: none;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    border: 1px solid #e0e0e0;
}

.chat-widget-typing.active {
    display: block;
}

.chat-widget-typing-dots {
    display: flex;
    gap: 4px;
}

.chat-widget-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.chat-widget-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-widget-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ========================================
   INPUT DO CHAT
======================================== */
#chat-widget-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

#chat-widget-input-form {
    display: flex;
    gap: 8px;
}

#chat-widget-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

#chat-widget-input:focus {
    border-color: #667eea;
}

#chat-widget-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

#chat-widget-send:hover {
    transform: scale(1.05);
}

#chat-widget-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   SCROLLBAR CUSTOMIZADA
======================================== */
#chat-widget-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-widget-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

#chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ========================================
   RESPONSIVO - MOBILE
======================================== */
@media (max-width: 768px) {
    /* Container ocupa tela toda */
    #chat-widget-container {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
    }
    
    /* Elementos dentro do container são clicáveis */
    #chat-widget-container > * {
        pointer-events: auto;
    }
    
    /* Botão fixo no canto */
    #chat-widget-button {
        position: fixed;
        bottom: 15px;
        right: 15px;
        z-index: 10000;
    }
    
    /* Janela ocupa tela toda */
    #chat-widget-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 9999;
    }
    
    /* Header sem border-radius */
    #chat-widget-header {
        border-radius: 0;
        padding: 15px;
    }
    
    /* Mensagens ocupam altura disponível */
    #chat-widget-messages {
        padding: 15px;
        height: calc(100% - 140px);
    }
    
    /* Mensagens mais largas no mobile */
    .chat-widget-message-content {
        max-width: 85%;
        font-size: 15px;
    }
    
    /* Input area */
    #chat-widget-input-area {
        padding: 12px;
    }
    
    /* Input maior no mobile */
    #chat-widget-input {
        font-size: 16px;
        padding: 14px 18px;
    }
    
    /* Botão enviar maior */
    #chat-widget-send {
        width: 48px;
        height: 48px;
    }
}

/* ========================================
   RESPONSIVO - TABLET
======================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    #chat-widget-window {
        width: 360px;
        height: 550px;
    }
}

/* ========================================
   RESPONSIVO - DESKTOP PEQUENO
======================================== */
@media (min-width: 1025px) and (max-width: 1366px) {
    #chat-widget-window {
        width: 380px;
        height: 600px;
    }
}

/* ========================================
   RESPONSIVO - DESKTOP GRANDE
======================================== */
@media (min-width: 1367px) {
    #chat-widget-window {
        width: 400px;
        height: 650px;
    }
}
