/* AI Chat Engine Pro Frontend Styles */
.ai-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    direction: rtl;
}

.ai-chat-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.ai-chat-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

.ai-chat-widget.top-right {
    top: 20px;
    right: 20px;
}

.ai-chat-widget.top-left {
    top: 20px;
    left: 20px;
}

/* Widget Trigger Button */
.ai-widget-trigger {
    width: 60px;
    height: 60px;
    background: var(--ai-primary-color, #007cba);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
}

.ai-widget-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.ai-widget-icon {
    color: white;
    transition: transform 0.3s ease;
}

.ai-widget-trigger.active .ai-widget-icon {
    transform: rotate(45deg);
}

.ai-widget-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: var(--ai-chat-width, 400px);
    height: var(--ai-chat-height, 600px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s ease;
}

.ai-chat-window.visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Chat Header */
.ai-chat-header {
    background: var(--ai-primary-color, #007cba);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.ai-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-chat-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-chat-title p {
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

.ai-chat-header-actions {
    display: flex;
    gap: 8px;
}

.ai-chat-action-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.ai-chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Bot Selection */
.ai-bot-selection {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.ai-bot-selection-header h5 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #333;
}

.ai-bot-selection-header p {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #666;
}

.ai-bot-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-bot-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-bot-item:hover {
    border-color: var(--ai-primary-color, #007cba);
    background: rgba(0, 124, 186, 0.05);
}

.ai-bot-item.selected {
    border-color: var(--ai-primary-color, #007cba);
    background: rgba(0, 124, 186, 0.1);
}

.ai-bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
}

.ai-bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-bot-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ai-primary-color, #007cba);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.ai-bot-info h6 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #333;
}

.ai-bot-info p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

.ai-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-message {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.ai-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message-bot {
    align-self: flex-start;
}

.ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.ai-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ddd;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.ai-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
}

.ai-message-user .ai-message-bubble {
    background: var(--ai-user-bubble-color, #007cba);
    color: var(--ai-user-text-color, white);
    border-bottom-right-radius: 6px;
}

.ai-message-bot .ai-message-bubble {
    background: var(--ai-bot-bubble-color, #f1f1f1);
    color: var(--ai-bot-text-color, #333);
    border-bottom-left-radius: 6px;
}

.ai-message-time {
    font-size: 11px;
    color: #999;
    text-align: center;
}

/* Typing Indicator */
.ai-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f1f1f1;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.ai-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions */
.ai-quick-actions {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-quick-action {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-quick-action:hover {
    background: var(--ai-primary-color, #007cba);
    color: white;
    border-color: var(--ai-primary-color, #007cba);
}

/* Chat Input */
.ai-chat-input-container {
    padding: 16px;
    border-top: 1px solid #eee;
}

.ai-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    border: 2px solid #eee;
    border-radius: 24px;
    transition: border-color 0.2s ease;
}

.ai-input-wrapper:focus-within {
    border-color: var(--ai-primary-color, #007cba);
}

.ai-message-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    max-height: 100px;
    min-height: 20px;
    font-family: inherit;
}

.ai-input-actions {
    display: flex;
    gap: 4px;
}

.ai-input-action {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-input-action:hover {
    background: #f0f0f0;
    color: var(--ai-primary-color, #007cba);
}

.ai-send-button {
    background: var(--ai-primary-color, #007cba);
    color: white;
}

.ai-send-button:hover {
    background: #005a87;
}

.ai-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ai-char-counter {
    font-size: 11px;
    color: #999;
    text-align: left;
    margin-top: 4px;
}

/* Modals */
.ai-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
}

.ai-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.ai-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.ai-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ai-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.ai-modal-body {
    padding: 20px;
}

/* File Upload */
.ai-file-upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-file-upload-area:hover {
    border-color: var(--ai-primary-color, #007cba);
    background: rgba(0, 124, 186, 0.05);
}

.ai-upload-icon {
    color: #999;
    margin-bottom: 16px;
}

.ai-file-upload-area p {
    margin: 8px 0;
    color: #666;
}

.ai-upload-info {
    font-size: 12px;
    color: #999;
}

/* Voice Recording */
.ai-voice-recorder {
    text-align: center;
}

.ai-voice-visualizer {
    margin-bottom: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.ai-voice-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

.ai-voice-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid var(--ai-primary-color, #007cba);
    background: white;
    color: var(--ai-primary-color, #007cba);
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ai-voice-btn:hover {
    background: var(--ai-primary-color, #007cba);
    color: white;
}

.ai-voice-btn.recording {
    background: #ff4444;
    border-color: #ff4444;
    color: white;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.ai-voice-timer {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

/* Inline Chatbot */
.ai-chatbot-container {
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    display: flex;
    flex-direction: column;
}

.ai-chatbot-header {
    background: #f8f9fa;
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chatbot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.ai-chatbot-title h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #333;
}

.ai-chatbot-title p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

.ai-chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4CAF50;
}

.ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 300px;
}

.ai-chatbot-input {
    padding: 16px;
    border-top: 1px solid #eee;
}

.ai-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-input-container .ai-message-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 20px;
    resize: none;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.ai-input-container .ai-message-input:focus {
    border-color: var(--ai-primary-color, #007cba);
}

.ai-input-container .ai-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--ai-primary-color, #007cba);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-input-container .ai-send-button:hover {
    background: #005a87;
    transform: scale(1.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 20px;
        left: 20px;
    }
    
    .ai-widget-trigger {
        width: 50px;
        height: 50px;
    }
    
    .ai-chatbot-container {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 10px;
        left: 10px;
    }
    
    .ai-bot-list {
        gap: 8px;
    }
    
    .ai-bot-item {
        padding: 8px;
    }
    
    .ai-quick-actions {
        flex-direction: column;
        gap: 6px;
    }
}

/* Animations */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-message {
    animation: fadeIn 0.3s ease;
}

.ai-chat-window.opening {
    animation: slideInUp 0.3s ease;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ai-chat-window {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .ai-chat-header {
        background: var(--ai-primary-color, #007cba);
    }
    
    .ai-message-bot .ai-message-bubble {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .ai-input-wrapper {
        background: #4a5568;
        border-color: #718096;
    }
    
    .ai-message-input {
        background: transparent;
        color: #e2e8f0;
    }
    
    .ai-modal-content {
        background: #2d3748;
        color: #e2e8f0;
    }
}

/* Accessibility */
.ai-chat-widget [role="button"]:focus,
.ai-chat-widget button:focus {
    outline: 2px solid var(--ai-primary-color, #007cba);
    outline-offset: 2px;
}

.ai-message-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

/* Print Styles */
@media print {
    .ai-chat-widget {
        display: none;
    }
}
