/* ================================================
   SISTEMA DE TUTOR IA - ESTILOS
   ================================================ */

/* Botão Flutuante */
.ai-chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    animation: pulse 2s infinite;
}

.ai-chat-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.ai-chat-button i {
    font-size: 1.4rem;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 10px 40px rgba(102, 126, 234, 0.7);
    }
}

/* Container do Chat */
.ai-chat-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 650px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-container.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Header do Chat */
.ai-chat-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.ai-chat-header h3 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-status {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
}

.ai-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.ai-close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

/* Área de Mensagens */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Estilo de Mensagens */
.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease-out;
}

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

.ai-message-user {
    align-self: flex-end;
}

.ai-message-bot {
    align-self: flex-start;
}

.ai-message-content {
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message-user .ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-bot .ai-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Referências */
.ai-references {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 0.85rem;
}

.ai-ref-tag {
    display: inline-block;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 4px 10px;
    border-radius: 12px;
    margin: 4px 4px 0 0;
    font-size: 0.8rem;
}

/* Timestamp */
.ai-timestamp {
    font-size: 0.75rem;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.ai-message-user .ai-timestamp {
    text-align: right;
}

.ai-message-bot .ai-timestamp {
    text-align: left;
}

/* Typing Indicator */
.ai-typing .ai-message-content {
    padding: 20px 25px;
}

.ai-typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ai-typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Sugestões Rápidas */
.ai-suggestions {
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.ai-suggestion-btn {
    background: #f1f3f5;
    border: 1px solid #e9ecef;
    padding: 8px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    color: #333;
}

.ai-suggestion-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
}

/* Input Container */
.ai-chat-input-container {
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#aiChatInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    max-height: 120px;
    transition: border-color 0.3s;
}

#aiChatInput:focus {
    outline: none;
    border-color: #667eea;
}

.ai-send-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.ai-send-btn:active {
    transform: scale(0.95);
}

/* Scrollbar Personalizada */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 10px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Responsivo */
@media (max-width: 768px) {
    .ai-chat-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        height: calc(100vh - 100px);
    }
    
    .ai-chat-button {
        bottom: 20px;
        right: 20px;
        padding: 14px 20px;
    }
    
    .ai-chat-button span {
        display: none;
    }
}

/* Estados Especiais */
.ai-message.ai-error .ai-message-content {
    background: #fee2e2;
    color: #ef4444;
    border-left: 3px solid #ef4444;
}

.ai-message.ai-success .ai-message-content {
    background: #d1fae5;
    color: #10b981;
    border-left: 3px solid #10b981;
}

/* Animações de Entrada */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-container:not(.hidden) {
    animation: fadeInUp 0.3s ease-out;
}

/* Indicador de Nova Mensagem */
.ai-chat-button.has-new-message::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 1.5s infinite;
}

/* Loading Skeleton */
.ai-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    height: 16px;
    margin: 8px 0;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
