/* AI Chat Widget Styles */
#ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 80px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Chat Bubble */
.ai-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    color: white;
}

.ai-chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ai-chat-bubble:active {
    transform: scale(0.95);
}

.ai-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
}

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

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

/* Chat 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-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.ai-chat-status {
    font-size: 12px;
    opacity: 0.9;
}

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

.ai-icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background 0.2s;
}

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

/* Messages Container */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

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

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

/* Welcome Message */
.ai-welcome-message {
    text-align: center;
    padding: 20px;
}

.ai-welcome-message p {
    color: #4a5568;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.ai-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-quick-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    text-align: left;
    color: #2d3748;
}

.ai-quick-btn:hover {
    border-color: #667eea;
    background: #f7fafc;
    transform: translateY(-1px);
}

/* Message Styles */
.ai-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.ai-message-assistant {
    align-self: flex-start;
}

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

.ai-message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

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

.ai-message-assistant .ai-message-content {
    background: white;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.ai-message-error .ai-message-content {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
    border-bottom-left-radius: 4px;
}

.ai-message-time {
    font-size: 11px;
    color: #a0aec0;
    padding: 0 4px;
}

.ai-message-user .ai-message-time {
    text-align: right;
}

/* Message Formatting */
.ai-message-content strong {
    font-weight: 600;
}

.ai-message-content em {
    font-style: italic;
}

.ai-message-content pre {
    background: #2d3748;
    color: #f7fafc;
    padding: 8px 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-message-content code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* Loading Indicator */
.ai-chat-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    color: #718096;
}

.ai-typing-indicator {
    display: flex;
    gap: 4px;
}

.ai-typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: typing 1.4s infinite;
}

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

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

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

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

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

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

.ai-chat-input::placeholder {
    color: #a0aec0;
}

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

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

.ai-send-btn:active {
    transform: scale(0.95);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    #ai-chat-widget {
        bottom: 100px;
        right: 15px;
    }

    .ai-chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        max-width: 100%;
        max-height: 600px;
    }

    .ai-chat-bubble {
        width: 56px;
        height: 56px;
    }
}

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

[dir="rtl"] .ai-chat-header-content {
    flex-direction: row-reverse;
}

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

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

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

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

[dir="rtl"] .ai-message-user .ai-message-time {
    text-align: left;
}

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

@media (max-width: 768px) {
    [dir="rtl"] #ai-chat-widget {
        left: 15px;
        bottom: 100px;
    }
}
