/**
 * Enhanced AI Assistant Styles
 * Improved positioning, dragging, resizing, and animations
 */

/* AI Assistant Window - Enhanced Positioning */
.ai-chat-window {
    position: fixed !important;
    bottom: 80px !important;
    right: 20px !important;
    width: 380px;
    height: 500px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform-origin: bottom right !important;
    transition: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-chat-window {
        background: #1a1a1a;
        border-color: #333;
        color: white;
    }
}

/* Drag Handle */
.ai-drag-handle {
    width: 100%;
    height: 20px;
    background: linear-gradient(45deg, #007bff, #0056b3);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
}

.ai-drag-handle:active {
    cursor: grabbing;
}

.ai-drag-handle i {
    opacity: 0.7;
}

/* Enhanced Header */
.ai-chat-header {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    display: flex;
    justify-content: between;
    align-items: center;
}

@media (prefers-color-scheme: dark) {
    .ai-chat-header {
        background: #2a2a2a;
        border-bottom-color: #444;
    }
}

/* Enhanced Messages Container with Auto-scroll */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    scroll-behavior: smooth;
}

/* Auto-scroll to bottom styling */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Message styling with better spacing */
.ai-message {
    margin-bottom: 15px;
    opacity: 0;
    transform: translateY(10px);
    animation: messageAppear 0.3s ease forwards;
}

@keyframes messageAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Resize Button */
.ai-btn#ai-resize-toggle {
    background: none;
    border: none;
    color: #666;
    padding: 5px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.ai-btn#ai-resize-toggle:hover {
    background: #e9ecef;
    color: #007bff;
}

/* Large size state */
.ai-chat-window.large-size {
    width: 500px !important;
    height: 650px !important;
}

/* Minimized state */
.ai-chat-window.minimized {
    height: 60px !important;
    overflow: hidden;
}

.ai-chat-window.minimized .ai-chat-messages,
.ai-chat-window.minimized .ai-chat-input-container,
.ai-chat-window.minimized .ai-quick-actions {
    display: none !important;
}

/* Animation for opening from toggle button */
.ai-chat-window.expanding {
    animation: expandFromButton 0.3s ease-out;
}

@keyframes expandFromButton {
    0% {
        transform: scale(0.1);
        opacity: 0;
        transform-origin: bottom right;
    }
    100% {
        transform: scale(1);
        opacity: 1;
        transform-origin: bottom right;
    }
}

/* Enhanced Toggle Button Animation */
.ai-assistant-toggle.expanding {
    animation: togglePulse 0.4s ease;
}

@keyframes togglePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Action Feedback Notifications */
.ai-action-feedback {
    border-radius: 5px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: feedbackSlideIn 0.3s ease;
}

@keyframes feedbackSlideIn {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.ai-action-feedback.success {
    background: linear-gradient(45deg, #28a745, #20c997) !important;
}

.ai-action-feedback.error {
    background: linear-gradient(45deg, #dc3545, #fd7e14) !important;
}

/* Enhanced Input Container */
.ai-chat-input-container {
    padding: 15px;
    border-top: 1px solid #eee;
    background: white;
}

@media (prefers-color-scheme: dark) {
    .ai-chat-input-container {
        background: #1a1a1a;
        border-top-color: #444;
    }
}

/* Persistent Window - stays visible across page navigation */
.ai-chat-window.persistent {
    position: fixed !important;
    z-index: 999999 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ai-chat-window {
        width: calc(100vw - 40px) !important;
        max-width: 380px;
        right: 20px !important;
        bottom: 20px !important;
    }
    
    .ai-chat-window.large-size {
        width: calc(100vw - 40px) !important;
        max-width: 450px;
        height: 80vh !important;
        max-height: 600px;
    }
}

/* Improved Typography */
.ai-message-text {
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message-text strong {
    color: #007bff;
}

/* Better Quick Actions */
.ai-quick-actions {
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

@media (prefers-color-scheme: dark) {
    .ai-quick-actions {
        background: #2a2a2a;
        border-bottom-color: #444;
    }
}

.quick-action-btn {
    font-size: 12px;
    padding: 6px 10px;
    margin: 2px;
    border-radius: 15px;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}