/* ═══════════════════════════════════════════════════
   AI CHAT ASSISTANT — ImportControl
   Branded conversational UI aligned with Fluent tokens
   ═══════════════════════════════════════════════════ */

/* ── Toggle Button ── */
.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-pill);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--text-inverse);
    background: var(--brand-primary);
    box-shadow:
        0 4px 16px rgba(0, 120, 212, 0.30),
        0 1px 4px rgba(0, 120, 212, 0.15);
    transition:
        transform var(--transition-spring),
        box-shadow var(--transition),
        background var(--transition);
}

.chat-toggle-btn:hover {
    transform: scale(1.06);
    background: var(--brand-hover);
    box-shadow:
        0 6px 24px rgba(0, 120, 212, 0.40),
        0 2px 8px rgba(0, 120, 212, 0.20);
}

.chat-toggle-btn:active {
    transform: scale(0.97);
}

.chat-toggle-btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 3px;
}

.chat-toggle-btn .chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-pill);
    background: var(--danger);
    border: 2px solid var(--white);
    display: none;
}

/* ── Chat Window ── */
.chat-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 9998;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatWindowOpen 0.3s var(--ease-decelerate) both;
}

@keyframes chatWindowOpen {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Header ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--brand-primary);
    color: var(--text-inverse);
    flex-shrink: 0;
    position: relative;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 18px;
    right: 18px;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-header-text h6 {
    margin: 0;
    font-size: 14px;
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    letter-spacing: -0.01em;
}

.chat-header-text small {
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.7);
}

.chat-header-close {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-inverse);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition:
        background var(--transition),
        border-color var(--transition);
}

.chat-header-close:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.15);
}

.chat-header-close:focus-visible {
    outline: 2px solid var(--text-inverse);
    outline-offset: 1px;
}

/* ── Messages Area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--surface-page);
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-200);
    border-radius: var(--radius-pill);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gray-300);
}

/* ── Message Bubbles ── */
.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: chatMsgEnter 0.25s var(--ease-decelerate) both;
}

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

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-msg.user .chat-msg-avatar {
    background: var(--brand-primary);
    color: var(--text-inverse);
}

.chat-msg.bot .chat-msg-avatar {
    background: var(--brand-wash);
    color: var(--brand-primary);
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    line-height: var(--leading-normal);
    word-break: break-word;
    white-space: pre-wrap;
    font-family: var(--font-sans);
}

.chat-msg.user .chat-msg-bubble {
    background: var(--brand-primary);
    color: var(--text-inverse);
    border-bottom-right-radius: var(--radius-sm);
}

.chat-msg.bot .chat-msg-bubble {
    background: var(--surface-card);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: var(--radius-sm);
}

/* ── Typing Indicator ── */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 4px 4px;
    font-size: var(--text-sm);
    color: var(--text-muted);
    animation: chatMsgEnter 0.2s var(--ease-decelerate) both;
}

.chat-typing-dots {
    display: flex;
    gap: 4px;
}

.chat-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: var(--radius-pill);
    background: var(--gray-300);
    animation: chatDotPulse 1.4s ease-in-out infinite;
}

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

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

@keyframes chatDotPulse {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
        background: var(--brand-primary);
    }
}

/* ── Welcome Screen ── */
.chat-welcome {
    text-align: center;
    padding: 32px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-active) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-inverse);
    margin-bottom: var(--space-4);
    box-shadow: 0 4px 16px rgba(0, 120, 212, 0.25);
}

.chat-welcome h6 {
    font-size: 15px;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin: 0 0 var(--space-1-5);
    letter-spacing: -0.01em;
}

.chat-welcome p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: var(--leading-relaxed);
    max-width: 260px;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
    width: 100%;
}

.chat-suggestion-chip {
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: var(--weight-medium);
    font-family: var(--font-sans);
    cursor: pointer;
    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

.chat-suggestion-chip:hover {
    background: var(--brand-wash);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    box-shadow: var(--shadow-xs);
}

.chat-suggestion-chip:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 1px;
}

/* ── Input Area ── */
.chat-input-area {
    padding: 14px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-card);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    padding: 9px 14px;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--surface-card);
    outline: none;
    resize: none;
    min-height: 38px;
    max-height: 80px;
    line-height: var(--leading-normal);
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

.chat-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.12);
}

.chat-input::placeholder {
    color: var(--text-disabled);
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: none;
    background: var(--brand-primary);
    color: var(--text-inverse);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    transition:
        background var(--transition),
        transform var(--transition-fast),
        box-shadow var(--transition);
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--brand-hover);
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.25);
    transform: translateY(-1px);
}

.chat-send-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.chat-send-btn:disabled {
    background: var(--gray-150);
    color: var(--text-disabled);
    cursor: not-allowed;
    box-shadow: none;
}

.chat-send-btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .chat-toggle-btn {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }

    .chat-welcome {
        padding: 24px 16px 20px;
    }

    .chat-suggestions {
        gap: 6px;
    }

    .chat-suggestion-chip {
        font-size: 11px;
        padding: 6px 12px;
    }
}
