/* ===== AI Assistant - Glassmorphism Chat (IPS Lab) ===== */

.ai-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue, #3b82f6), var(--accent-cyan, #06b6d4));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    z-index: 9999;
    transition: all 0.3s ease;
    padding: 0;
    font-size: 1.5rem;
}

.ai-fab:hover {
    box-shadow: 0 6px 28px rgba(59, 130, 246, 0.6);
    transform: scale(1.05);
}

.ai-fab.open {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

/* Pulse ring */
.ai-fab::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent-blue, #3b82f6);
    animation: ai-pulse 2s ease-out infinite;
    pointer-events: none;
}

.ai-fab.open::before {
    display: none;
}

@keyframes ai-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Chat Window */
.ai-chat-window {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    height: 520px;
    display: none;
    flex-direction: column;
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    overflow: hidden;
    animation: ai-window-in 0.3s ease;
}

.ai-chat-window.open {
    display: flex;
}

@keyframes ai-window-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    background: rgba(59, 130, 246, 0.08);
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    flex-shrink: 0;
}

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

.ai-chat-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue, #3b82f6), var(--accent-cyan, #06b6d4));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.ai-chat-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary, #e8ecf4);
}

.ai-chat-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted, #5a6478);
}

/* Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 2px;
}

.ai-message-row {
    display: flex;
}

.ai-message-row.user {
    justify-content: flex-end;
}

.ai-message-row.model {
    justify-content: flex-start;
}

.ai-message {
    max-width: 85%;
    padding: 0.7rem 1rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
}

.ai-message.user {
    background: linear-gradient(135deg, var(--accent-blue, #3b82f6), var(--accent-cyan, #06b6d4));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-message.model {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #e8ecf4);
    border-bottom-left-radius: 4px;
}

.ai-message strong {
    color: #fff;
    font-weight: 700;
}

/* Welcome hints */
.ai-welcome-hints {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.5rem 0;
}

.ai-hint-chip {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 0.5rem 0.8rem;
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--accent-cyan, #06b6d4);
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    font-family: inherit;
}

.ai-hint-chip:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Typing indicator */
.ai-typing {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted, #5a6478);
}

.ai-typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-blue, #3b82f6);
    animation: ai-dot-bounce 1.4s ease-in-out infinite;
    margin-right: 3px;
}

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

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

@keyframes ai-dot-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input */
.ai-chat-input-area {
    padding: 0.8rem 1rem;
    border-top: 1px solid rgba(59, 130, 246, 0.15);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.ai-input-wrapper {
    position: relative;
}

.ai-chat-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1rem;
    padding-right: 3rem;
    border-radius: 12px;
    color: var(--text-primary, #e8ecf4);
    font-size: 0.88rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.ai-chat-input:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ai-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.ai-send-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, color 0.2s;
    font-size: 1rem;
}

.ai-send-btn:hover {
    background: var(--accent-blue, #3b82f6);
    color: #fff;
}

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

/* Mobile responsive */
@media (max-width: 480px) {
    .ai-chat-window {
        right: 0.5rem;
        left: 0.5rem;
        bottom: 5rem;
        width: auto;
        height: 420px;
    }

    .ai-fab {
        bottom: 1rem;
        right: 1rem;
    }
}