/* AI Chat Widget */
.ai-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.45);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    max-width: 320px;
}

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

.ai-chat-btn svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.ai-chat-btn-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-btn.ai-chat-btn--hidden {
    display: none;
}

/* Chat Window */
.ai-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 48px);
    background: #1a1a2e;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Montserrat', sans-serif;
}

.ai-chat-window.ai-chat-window--open {
    display: flex;
    animation: aiChatSlideUp 0.3s ease-out;
}

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

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

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.ai-chat-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.ai-chat-header-info span {
    font-size: 11px;
    opacity: 0.8;
}

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

.ai-chat-header-actions button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

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

/* Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

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

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

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

.ai-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-chat-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-chat-msg--bot {
    align-self: flex-start;
    background: #252545;
    color: #e0e0e0;
    border-bottom-left-radius: 4px;
}

.ai-chat-msg--bot a {
    color: #8e9aff;
    text-decoration: underline;
}

/* Typing indicator */
.ai-chat-typing {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    background: #252545;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.ai-chat-typing.ai-chat-typing--visible {
    display: flex;
}

.ai-chat-typing span {
    display: block;
    width: 7px;
    height: 7px;
    background: #8e9aff;
    border-radius: 50%;
    animation: aiTypingDot 1.4s infinite;
}

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

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

@keyframes aiTypingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Welcome message */
.ai-chat-welcome {
    text-align: center;
    color: #888;
    font-size: 12px;
    padding: 20px 10px;
    line-height: 1.6;
}

.ai-chat-welcome strong {
    color: #b0b8ff;
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
}

/* Input area */
.ai-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #2a2a4a;
    background: #16162b;
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    background: #252545;
    border: 1px solid #3a3a5a;
    border-radius: 20px;
    padding: 10px 16px;
    color: #e0e0e0;
    font-size: 13px;
    font-family: 'Montserrat', sans-serif;
    outline: none;
    resize: none;
    max-height: 80px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

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

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

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

.ai-chat-send:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

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

/* Error message */
.ai-chat-msg--error {
    align-self: center;
    background: rgba(224, 63, 79, 0.15);
    color: #ff6b7a;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    text-align: center;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .ai-chat-btn {
        bottom: 16px;
        right: 16px;
        padding: 12px 16px;
        font-size: 12px;
        max-width: 260px;
    }

    .ai-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .ai-chat-btn-text {
        display: none;
    }

    .ai-chat-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        padding: 0;
        justify-content: center;
    }
}
