/**
 * Local AI Chat Widget Styles
 * Responsive and customizable AI chat interface
 */

.ai-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    max-width: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

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

.ai-chat-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.ai-chat-status {
    display: flex;
    align-items: center;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

.status-dot.connected {
    background-color: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.status-dot.connected.local {
    background-color: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.status-dot.connected.remote {
    background-color: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

.status-dot.demo {
    background-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
    animation: demo-pulse 2s infinite;
}

@keyframes demo-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.status-dot.disconnected {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

/* Model Selector */
.ai-chat-model-selector {
    padding: 12px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ai-chat-model-selector label {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
}

#ai-model-select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #374151;
    min-width: 150px;
    cursor: pointer;
}

#ai-model-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.model-info {
    font-size: 11px;
    color: #6b7280;
    background: #e5e7eb;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Messages Container */
.ai-chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Individual Messages */
.ai-chat-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

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

.ai-chat-message.ai {
    align-items: flex-start;
}

.ai-chat-message.system {
    align-items: center;
}

.ai-chat-message.loading {
    align-items: flex-start;
}

.ai-chat-message.error {
    align-items: flex-start;
}

/* Error Message Content */
.ai-chat-message.error .message-content {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-bottom-left-radius: 6px;
    border-left: 4px solid #ef4444;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

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

/* AI Messages */
.ai-chat-message.ai .message-content {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
}

/* System Messages */
.ai-chat-message.system .message-content {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    font-style: italic;
    max-width: 100%;
    text-align: center;
    font-size: 13px;
}

/* Loading Messages */
.ai-chat-message.loading .message-content {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
    font-style: italic;
    position: relative;
}

.ai-chat-message.loading .message-content::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #6b7280;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

/* Error Messages */
.ai-chat-message.error .message-content {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-bottom-left-radius: 6px;
}

/* Input Container */
.ai-chat-input-container {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    align-items: center;
}

#ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    background: white;
    color: #374151;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#ai-chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#ai-chat-input:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

#ai-chat-send {
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 48px;
    height: 48px;
}

#ai-chat-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

#ai-chat-send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-icon {
    font-size: 16px;
    font-weight: bold;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.ai-chat-message {
    animation: slideIn 0.3s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-chat-widget {
        border-radius: 0;
        height: 100vh;
        max-height: none;
    }
    
    .ai-chat-messages {
        height: calc(100vh - 200px);
    }
    
    .ai-chat-model-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    #ai-model-select {
        min-width: 100%;
    }
    
    .message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .ai-chat-header {
        padding: 12px 16px;
    }
    
    .ai-chat-title {
        font-size: 16px;
    }
    
    .ai-chat-messages {
        padding: 16px;
        height: calc(100vh - 180px);
    }
    
    .ai-chat-input-container {
        padding: 12px 16px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 10px 14px;
    }
}

/* Theme Variants */
.ai-chat-widget.dark {
    background: #1f2937;
    border-color: #374151;
}

.ai-chat-widget.dark .ai-chat-messages {
    background: #1f2937;
}

.ai-chat-widget.dark .ai-chat-message.ai .message-content {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
}

.ai-chat-widget.dark #ai-chat-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

.ai-chat-widget.dark .ai-chat-model-selector,
.ai-chat-widget.dark .ai-chat-input-container {
    background: #374151;
    border-color: #4b5563;
}

/* Compact theme */
.ai-chat-widget.compact .ai-chat-messages {
    height: 300px;
}

.ai-chat-widget.compact .ai-chat-header {
    padding: 12px 16px;
}

.ai-chat-widget.compact .ai-chat-title {
    font-size: 16px;
}

/* Minimal theme */
.ai-chat-widget.minimal {
    box-shadow: none;
    border: 2px solid #e5e7eb;
}

.ai-chat-widget.minimal .ai-chat-header {
    background: #f9fafb;
    color: #374151;
}

.ai-chat-widget.minimal .ai-chat-message.user .message-content {
    background: #3b82f6;
}

.ai-chat-widget.minimal #ai-chat-send {
    background: #3b82f6;
}
