/* ai-chat.css - PERFORMANCE OPTIMIZED */
/* Using CSS variables for better performance */

:root {
    --primary-color: #2563eb;
    --primary-light: #5790ec;
    --primary-dark: #1d4ed8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #ffffff;
    --bg-light: #f8fafc;
    --border-color: #e5e7eb;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --shadow-light: 0 4px 15px rgba(37, 99, 235, 0.1);
    --shadow-medium: 0 10px 40px rgba(37, 99, 235, 0.15);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* Bubble - Minimal styles */
#ai-chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-light);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    transition: transform var(--transition-normal), 
                box-shadow var(--transition-normal);
    will-change: transform, box-shadow;
    backface-visibility: hidden;
}

#ai-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.2);
}

/* Container - Optimized rendering */
.ai-chat-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 350px;
    height: 500px;
    z-index: 10001;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
    contain: layout style paint; /* Performance optimization */
}

/* Window - Hardware accelerated */
.ai-chat-window {
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-medium);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transform: translateZ(0); /* GPU acceleration */
}

/* Header */
.ai-drag-header {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* Allow text truncation */
}

.ai-drag-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-count {
    font-size: 11px;
    opacity: 0.8;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Buttons - Optimized */
.btn-clear, .btn-close {
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    gap: 4px;
}

.btn-clear:hover {
    background: rgba(255, 255, 255, 0.25);
}

.btn-close {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages area - Performance optimized */
.ai-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: var(--bg-light);
    contain: content; /* Performance */
    overscroll-behavior: contain; /* Better scroll */
}

/* Message styles - Minimal repaints */
.message-user, .message-ai {
    padding: 10px 14px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    max-width: 85%;
    border-radius: var(--radius-xl);
    animation: message-appear 0.2s ease;
    will-change: transform, opacity;
}

@keyframes message-appear {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: var(--radius-sm);
}

.message-ai {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    margin-right: auto;
    border-bottom-left-radius: var(--radius-sm);
}

.continue-message {
    background: #e8f4fd;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 11px;
    color: #0369a1;
    text-align: center;
    border: 1px solid #bae6fd;
}

/* Typing indicator */
.typing-indicator {
    background: var(--bg-color) !important;
}

.typing-content {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 12px;
}

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

.typing-dots span {
    width: 5px;
    height: 5px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

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

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

/* Input area */
.ai-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ai-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    outline: none;
    font-size: 13px;
    background: var(--bg-light);
    transition: border-color var(--transition-fast);
}

.ai-input:focus {
    border-color: var(--primary-light);
    background: var(--bg-color);
}

.ai-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
}

.ai-button:hover {
    background: var(--primary-dark);
}

.ai-button:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

/* Resize handle */
.resizing-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: var(--primary-light);
    cursor: nwse-resize;
    border-bottom-right-radius: var(--radius-lg);
}

/* Notifications */
.ai-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10002;
    animation: slide-in 0.3s ease, fade-out 0.3s ease 1.7s;
    font-size: 13px;
    max-width: 300px;
    backdrop-filter: blur(10px);
}

.ai-notification.success {
    background: rgba(16, 185, 129, 0.95);
    color: white;
    border: 1px solid #10b981;
}

.ai-notification.error {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border: 1px solid #ef4444;
}

.ai-notification.info {
    background: rgba(59, 130, 246, 0.95);
    color: white;
    border: 1px solid #3b82f6;
}

@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

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

.ai-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Performance classes */
.perf-hidden {
    display: none !important;
}

.perf-opacity-0 {
    opacity: 0 !important;
}

.perf-opacity-1 {
    opacity: 1 !important;
}
