/* AI Chat Widget Styles */

#ai-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Chat Button */
#ai-chat-button {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    min-width: 60px;
    height: 60px;
    padding: 0 20px;
    border-radius: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    color: white;
    font-size: 24px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    z-index: 10000;
}

#ai-chat-button span {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

#ai-chat-button:hover {
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

#ai-chat-button:active {
    cursor: grabbing;
}

#ai-chat-button.active {
    display: none;
}

/* Chat Window */
#ai-chat-window {
    display: none;
    flex-direction: column;
    position: fixed;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    z-index: 9999;
}

#ai-chat-window.active {
    display: flex;
}

@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 h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#ai-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f8fa;
}

.chat-message {
    margin-bottom: 12px;
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.assistant {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.user .chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 10px 14px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    max-width: 75%;
}

.typing-indicator.active {
    display: block;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Chat Input */
#ai-chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
}

#ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#ai-chat-input:focus {
    border-color: #667eea;
}

#ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#ai-chat-send:hover:not(:disabled) {
    transform: scale(1.1);
}

#ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 20px;
    color: #666;
}

.welcome-message h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #333;
}

.welcome-message p {
    margin: 0;
    font-size: 13px;
}

/* Error Message */
.error-message {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 8px;
    margin: 8px 16px;
    font-size: 13px;
    text-align: center;
}

/* Rate Limit Warning */
.rate-limit-warning {
    background: #ffeaa7;
    color: #856404;
    padding: 10px;
    border-radius: 8px;
    margin: 8px 16px;
    font-size: 13px;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #ai-chat-button {
        min-width: 50px;
        width: 50px;
        height: 50px;
        font-size: 20px;
        padding: 0 10px;
    }

    #ai-chat-button span {
        display: none;
    }

    #ai-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        left: 10px !important;
        top: 50px !important;
    }
}

/* Scrollbar Styling */
#ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#ai-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#ai-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

#ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}
