/* ==================== AI Chat Component — Spectrum Vision ==================== */
/*
 * Wave 2.2 re-skin: migrated from SPEC-1 dark palette to Spectrum Vision tokens.
 * Surface: var(--bg-elevated) / var(--bg-sunken) / var(--border)
 * Accent: var(--orange) / var(--orange-hover)
 * Typography: IBM Plex Sans (body), IBM Plex Mono (timestamps)
 */
.ai-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: var(--font-sans);
}

/* ── Toggle Button (FAB) ─────────────────────────────────── */
.ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), var(--orange-hover));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px oklch(66% 0.18 50 / 0.35);
    transition: box-shadow 200ms ease, transform 200ms ease;
    position: relative;
}

.ai-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px oklch(66% 0.18 50 / 0.50);
}

.ai-chat-toggle .robot-icon {
    font-size: 1.8rem;
}

.ai-chat-toggle .pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--orange);
    animation: ai-pulse-ring 2s ease-out infinite;
}

@keyframes ai-pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* ── Chat Panel ──────────────────────────────────────────── */
.ai-chat-panel {
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ai-slide-up 0.3s ease-out;
}

@keyframes ai-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Chat Header ─────────────────────────────────────────── */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--bg-sunken), var(--bg-elevated));
    border-bottom: 1px solid var(--border);
}

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

.ai-chat-header .header-icon {
    font-size: 1.4rem;
}

.ai-chat-header .header-text h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    margin: 0;
    letter-spacing: -0.01em;
}

.ai-chat-header .status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--green);
    margin-top: 2px;
}

.ai-chat-header .status-dot {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    animation: ai-status-pulse 2s ease-in-out infinite;
}

@keyframes ai-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.ai-chat-header .close-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, color 120ms ease;
}

.ai-chat-header .close-btn:hover {
    background: var(--bg-sunken);
    color: var(--fg);
}

/* ── Quick Actions ───────────────────────────────────────── */
.ai-chat-quick-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}

.ai-chat-quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-action-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--fg-muted);
    font-size: 11px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
    white-space: nowrap;
}

.quick-action-btn:hover:not(:disabled) {
    background: var(--orange);
    color: white;
    border-color: var(--orange);
}

.quick-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quick-action-icon {
    font-size: 12px;
}

/* ── Messages Area ───────────────────────────────────────── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

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

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

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* ── Empty State ─────────────────────────────────────────── */
.ai-chat-messages .empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--fg-muted);
    padding: 20px;
}

.ai-chat-messages .empty-icon {
    font-size: 2.8rem;
    margin-bottom: 14px;
    opacity: 0.65;
}

.ai-chat-messages .empty-state p {
    margin: 3px 0;
    font-size: 13px;
    color: var(--fg);
}

.ai-chat-messages .empty-state .hint {
    font-size: 11px;
    color: var(--fg-subtle);
    margin-top: 6px;
}

/* ── Chat Messages ───────────────────────────────────────── */
.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    animation: ai-message-in 0.25s ease-out;
}

@keyframes ai-message-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.message-user {
    align-self: flex-end;
    background: var(--orange);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-message.message-assistant {
    align-self: flex-start;
    background: var(--bg-sunken);
    color: var(--fg);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

.chat-message.message-system {
    align-self: center;
    background: oklch(95% 0.025 25);
    color: var(--red);
    border: 1px solid oklch(88% 0.060 25);
    font-size: 11px;
    text-align: center;
}

.chat-message .message-content {
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chat-message .message-time {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    opacity: 0.6;
    margin-top: 5px;
    text-align: right;
}

.chat-message.message-assistant .message-time {
    text-align: left;
}

/* ── Loading / Typing Indicator ──────────────────────────── */
.chat-message.loading {
    padding: 14px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--fg-subtle);
    border-radius: 50%;
    animation: ai-typing-bounce 1.4s ease-in-out infinite;
}

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

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

/* ── Input Area ──────────────────────────────────────────── */
.ai-chat-input {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--bg-sunken), var(--bg-elevated));
    border-top: 1px solid var(--border);
}

.ai-chat-input input {
    flex: 1;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.ai-chat-input input::placeholder {
    color: var(--fg-subtle);
}

.ai-chat-input input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px oklch(66% 0.180 50 / 0.12);
}

.ai-chat-input input:disabled {
    opacity: 0.6;
}

.ai-chat-input .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--orange);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, transform 120ms ease;
    box-shadow: 0 1px 0 oklch(50% 0.180 48 / 0.4);
}

.ai-chat-input .send-btn:hover:not(:disabled) {
    background: var(--orange-hover);
    transform: scale(1.05);
}

.ai-chat-input .send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Mobile Responsive ───────────────────────────────────── */
@media (max-width: 480px) {
    .ai-chat-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        border-radius: var(--radius);
    }

    .ai-chat-container {
        bottom: 10px;
        right: 10px;
    }
}
