/* ==========================================
   AI CHAT WIDGET STYLES
   ========================================== */

/* Widget Container */
#ai-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
.ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

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

.ai-chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s ease;
}

.ai-chat-toggle.open svg {
    transform: rotate(180deg);
}

/* Notification Badge */
.ai-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    display: none;
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.ai-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Chat Header */
.ai-chat-header {
    padding: 16px 20px;
    background: var(--primary-color, #3b82f6);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

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

.ai-chat-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

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

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

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

.ai-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

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

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-chat-close svg {
    width: 18px;
    height: 18px;
    fill: white;
}

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

/* Message Bubbles */
.ai-chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

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

.ai-chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-chat-message.user .ai-chat-bubble {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant .ai-chat-bubble {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ai-chat-timestamp {
    font-size: 11px;
    color: #94a3b8;
    padding: 0 4px;
}

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

/* Typing Indicator */
.ai-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    width: fit-content;
}

.ai-chat-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-chat-typing span:nth-child(1) { animation-delay: 0s; }
.ai-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Quick Replies */
.ai-chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.ai-chat-quick-reply {
    padding: 8px 14px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-chat-quick-reply:hover {
    background: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
    color: white;
}

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

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

.ai-chat-input:focus {
    border-color: var(--primary-color, #3b82f6);
}

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

.ai-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-send:hover {
    background: var(--primary-color, #2563eb);
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Error State */
.ai-chat-error {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: 12px;
    color: #dc2626;
    font-size: 13px;
    margin: 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-error svg {
    width: 18px;
    height: 18px;
    fill: #dc2626;
    flex-shrink: 0;
}

/* Offline State */
.ai-chat-offline {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
}

.ai-chat-offline svg {
    width: 48px;
    height: 48px;
    fill: #94a3b8;
    margin-bottom: 16px;
}

.ai-chat-offline p {
    margin: 0 0 16px 0;
    font-size: 14px;
}

.ai-chat-offline-btn {
    padding: 10px 20px;
    background: var(--primary-color, #3b82f6);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ai-chat-offline-btn:hover {
    background: var(--primary-color, #2563eb);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #ai-chat-widget {
        bottom: 16px;
        right: 16px;
    }

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

    .ai-chat-window {
        bottom: 72px;
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: none;
        right: 0;
        border-radius: 12px;
    }

    .ai-chat-header {
        padding: 14px 16px;
    }

    .ai-chat-messages {
        padding: 16px;
    }

    .ai-chat-input-area {
        padding: 12px 16px;
    }

    .ai-chat-input {
        padding: 10px 14px;
    }

    .ai-chat-send {
        width: 40px;
        height: 40px;
    }
}

/* Dark Mode Support (if site uses dark mode) */
@media (prefers-color-scheme: dark) {
    .ai-chat-window {
        background: #1e293b;
    }

    .ai-chat-messages {
        background: #0f172a;
    }

    .ai-chat-message.assistant .ai-chat-bubble {
        background: #334155;
        color: #f1f5f9;
    }

    .ai-chat-typing {
        background: #334155;
    }

    .ai-chat-quick-replies {
        background: #1e293b;
        border-color: #334155;
    }

    .ai-chat-quick-reply {
        background: #334155;
        border-color: #475569;
        color: #e2e8f0;
    }

    .ai-chat-input-area {
        background: #1e293b;
        border-color: #334155;
    }

    .ai-chat-input {
        background: #0f172a;
        border-color: #334155;
        color: #f1f5f9;
    }

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

/* History Button */
.ai-chat-history-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    margin-right: 4px;
}

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

.ai-chat-history-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* History Panel */
.ai-chat-history-panel {
    flex: 1;
    overflow-y: auto;
    background: #f8fafc;
    display: none;
}

.ai-chat-history-header {
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-history-header h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.ai-chat-new-chat-btn {
    padding: 6px 12px;
    background: var(--primary-color, #3b82f6);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ai-chat-new-chat-btn:hover {
    background: var(--primary-color, #2563eb);
}

.ai-chat-history-list {
    padding: 12px;
}

.ai-chat-history-item {
    background: white;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.ai-chat-history-item:hover {
    background: #f1f5f9;
    transform: translateX(2px);
}

.ai-chat-history-item-content {
    flex: 1;
    min-width: 0;
}

.ai-chat-history-item-preview {
    font-size: 14px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.ai-chat-history-item-meta {
    font-size: 12px;
    color: #64748b;
}

.ai-chat-history-item-arrow {
    width: 16px;
    height: 16px;
    fill: #94a3b8;
    flex-shrink: 0;
}

.ai-chat-history-empty {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
}

.ai-chat-history-empty p {
    margin: 0 0 16px 0;
    font-size: 14px;
}

.ai-chat-history-loading {
    padding: 40px;
    display: flex;
    justify-content: center;
}

/* Image Attachment */
.ai-chat-attach {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-attach:hover {
    background: #f1f5f9;
}

.ai-chat-attach svg {
    width: 22px;
    height: 22px;
    fill: #64748b;
}

.ai-chat-attach:hover svg {
    fill: var(--primary-color, #3b82f6);
}

/* Image Preview */
.ai-chat-image-preview {
    display: none;
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    align-items: center;
    gap: 12px;
}

.ai-chat-image-preview img {
    max-width: 100px;
    max-height: 80px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-chat-remove-image {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.ai-chat-remove-image:hover {
    background: #dc2626;
}

.ai-chat-remove-image svg {
    width: 14px;
    height: 14px;
    fill: white;
}

/* Voice Button */
.ai-chat-voice {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-voice:hover {
    background: #f1f5f9;
}

.ai-chat-voice svg {
    width: 22px;
    height: 22px;
    fill: #64748b;
}

.ai-chat-voice:hover svg {
    fill: var(--primary-color, #3b82f6);
}

.ai-chat-voice.recording {
    background: #ef4444;
    animation: pulse 1.5s infinite;
}

.ai-chat-voice.recording svg {
    fill: white;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Streaming Cursor */
.ai-chat-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: var(--primary-color, #3b82f6);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Tool Indicator */
.ai-chat-tool-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    font-size: 13px;
    color: #15803d;
    margin-top: 8px;
}

.ai-chat-tool-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #bbf7d0;
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

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

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