/* AI Chat Widget Styles */

#ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: inherit;
}

/* Floating Button */
.ai-chat-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.ai-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.ai-chat-btn i {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Chat Window */
.ai-chat-window {
    width: 400px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

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

.ai-chat-header-info {
    flex: 1;
}

.ai-chat-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-token-stats {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 4px;
}

.ai-chat-header-actions {
    display: flex;
    gap: 8px;
}

.ai-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.ai-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

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

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

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

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

/* Welcome Message */
.ai-welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.ai-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.ai-welcome-message h3 {
    color: #374151;
    margin-bottom: 8px;
    font-size: 20px;
}

.ai-welcome-message p {
    color: #6b7280;
    margin-bottom: 24px;
}

.ai-suggestions {
    text-align: right;
    font-size: 13px;
}

.ai-suggestions ul {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.ai-suggestions li {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
}

.ai-suggestions li i {
    color: #667eea;
    width: 20px;
}

/* Message Bubbles */
.ai-message {
    margin-bottom: 12px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.ai-message.user {
    justify-content: flex-end;
}

.ai-message.assistant {
    justify-content: flex-start;
}

.ai-message.system {
    justify-content: center;
}

.ai-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

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

.ai-message.assistant .ai-message-bubble {
    background: #e5e7eb;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.ai-message.system .ai-message-bubble {
    background: #fee2e2;
    color: #991b1b;
    border-radius: 8px;
    font-size: 13px;
}

.ai-message-metadata {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 11px;
    opacity: 0.8;
}

.ai-message-timestamp {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
}

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

.ai-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

.ai-chat-input:focus {
    border-color: #667eea;
}

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

.ai-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Indicator */
.ai-loading {
    position: absolute;
    bottom: 70px;
    left: 16px;
}

.ai-loading-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #e5e7eb;
    border-radius: 12px;
}

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

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

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

@keyframes typing {
    0%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-chat-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }

    #ai-chat-widget {
        bottom: 10px;
        right: 10px;
    }
}

/* RTL Support */
[dir="rtl"] #ai-chat-widget {
    left: 20px;
    right: auto;
}

[dir="rtl"] .ai-suggestions {
    text-align: right;
}

[dir="rtl"] .ai-suggestions li {
    flex-direction: row-reverse;
}

[dir="rtl"] .ai-message.user {
    justify-content: flex-start;
}

[dir="rtl"] .ai-message.assistant {
    justify-content: flex-end;
}

[dir="rtl"] .ai-message.user .ai-message-bubble {
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .ai-message.assistant .ai-message-bubble {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}
