/**
 * Floating AI Chat Bubble Styles
 * Global AI assistance component
 */

.floating-ai-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Inter', sans-serif;
}

/* Mobile optimization for floating chat */
@media (max-width: 768px) {
    .floating-ai-chat {
        bottom: 80px;
        right: 16px;
    }
    
    .ai-chat-toggle {
        width: 56px !important;
        height: 56px !important;
    }
    
    .ai-chat-toggle .material-icons {
        font-size: 24px !important;
    }
    
    #chat-toggle-icon {
        font-size: 24px !important;
    }
}

.ai-chat-toggle {
    width: 60px;
    height: 60px;
    background: #1976d2 !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(25, 118, 210, 0.4) !important;
    transition: all 0.3s ease;
    position: relative;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(25, 118, 210, 0.6) !important;
}

.ai-chat-toggle .material-icons {
    color: white;
    font-size: 28px;
}

/* Force clean icon display - no pseudo-elements */
#chat-toggle-icon {
    color: white !important;
    font-size: 28px !important;
    font-family: "Material Icons" !important;
}

/* Remove any pseudo-element content that might duplicate icons */
#chat-toggle-icon:before,
#chat-toggle-icon:after,
.ai-chat-toggle .material-icons:before,
.ai-chat-toggle .material-icons:after {
    content: none !important;
    display: none !important;
}

.pulse-ring {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    animation: pulse 2s infinite;
    opacity: 0.6;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-window.open {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

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

.ai-chat-header {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.ai-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
}

.ai-welcome-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ai-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-avatar .material-icons {
    color: white;
    font-size: 18px;
}

.ai-message-content {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
    flex: 1;
}

.ai-message-content p {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.ai-message-content p:last-child {
    margin-bottom: 0;
}

.ai-quick-actions {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-quick-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.ai-quick-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.ai-chat-input-area {
    padding: 1rem;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.ai-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 0.75rem 1rem;
    resize: none;
    outline: none;
    font-size: 0.875rem;
    font-family: inherit;
    max-height: 100px;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    border-color: #3b82f6;
}

.ai-send-button {
    background: #3b82f6;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.ai-send-button:hover {
    background: #1d4ed8;
}

.ai-send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.ai-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ai-message.user {
    flex-direction: row-reverse;
}

.ai-message.user .ai-message-content {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 12px;
}

.ai-typing-indicator {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ai-typing-dots {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* LaTeX and Mathematical Expression Styling */
.ai-message-content .MathJax {
    display: inline-block !important;
    margin: 0.25rem 0;
}

.ai-message-content .MathJax_Display {
    margin: 0.75rem 0 !important;
    text-align: center;
}

/* Code block styling */
.ai-message-content pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin: 0.5rem 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
}

.ai-message-content code {
    background: #f1f5f9;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
}

/* Table styling */
.ai-message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
    font-size: 0.8rem;
}

.ai-message-content th,
.ai-message-content td {
    border: 1px solid #e2e8f0;
    padding: 0.375rem;
    text-align: left;
}

.ai-message-content th {
    background: #f8fafc;
    font-weight: 600;
}

/* List styling */
.ai-message-content ul,
.ai-message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.ai-message-content li {
    margin: 0.25rem 0;
}

/* Header styling within messages */
.ai-message-content h1,
.ai-message-content h2,
.ai-message-content h3,
.ai-message-content h4 {
    color: #1e40af;
    margin: 0.75rem 0 0.25rem 0;
    font-weight: 600;
}

.ai-message-content h3 { font-size: 1rem; }
.ai-message-content h4 { font-size: 0.9rem; }

/* Mobile responsiveness */
@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 40px);
        height: 70vh;
        bottom: 80px;
        right: 20px;
    }
    
    .floating-ai-chat {
        bottom: 15px;
        right: 15px;
    }
    
    .ai-chat-toggle {
        width: 55px;
        height: 55px;
    }
    
    .ai-chat-toggle .material-icons {
        font-size: 24px;
    }
}