﻿/* ============================================================
   27. CHAT WIDGET — AI Assistant
   ============================================================ */

/* ── Floating Bubble ── */
.chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(236, 72, 153, 0.35);
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.45);
    background: var(--color-primary-hover);
}

.chat-bubble:active {
    transform: scale(0.95);
}

.chat-bubble-active {
    background: var(--color-primary-active);
}

/* ── Chat Panel ── */
.chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 1001;
    width: 380px;
    max-height: 520px;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ── Panel Header ── */
.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    flex-shrink: 0;
}

.chat-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: var(--text-sm);
}

/* Header action buttons (New Chat + Close) */
.chat-panel-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-btn {
    background: none;
    border: none;
    color: var(--color-text-inverse);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    transition: opacity var(--transition-fast), background-color var(--transition-fast);
}

.chat-header-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.15);
}

/* ── Messages Area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 340px;
    background: var(--color-bg);
}

/* ── Welcome Screen ── */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 16px;
    flex: 1;
}

.chat-welcome-title {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--color-text);
    margin-bottom: 8px;
}

.chat-welcome-text {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* ── Message Bubbles ── */
.chat-msg {
    display: flex;
    max-width: 85%;
}

.chat-msg-user {
    align-self: flex-end;
}

.chat-msg-assistant {
    align-self: flex-start;
}

.chat-msg-content {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: var(--text-sm);
    line-height: 1.5;
    word-break: break-word;
}

.chat-msg-user .chat-msg-content {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-bottom-right-radius: var(--border-radius-sm);
}

.chat-msg-assistant .chat-msg-content {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: var(--border-radius-sm);
}

/* ── Typing Indicator ── */
.chat-typing .chat-msg-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-text-muted);
    animation: chat-typing-bounce 1.2s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chat-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Confirm Bar ── */
.chat-confirm-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--color-warning-light);
    border-top: 1px solid #f59e0b;
    flex-shrink: 0;
}

.chat-confirm-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: #92400e;
}

.chat-confirm-actions {
    display: flex;
    gap: 6px;
}

.chat-confirm-actions .btn-sm {
    padding: 4px 12px;
    font-size: var(--text-xs);
}

/* ── Input Area ── */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-family: inherit;
    font-size: var(--text-sm);
    line-height: 1.4;
    color: var(--color-text);
    background: var(--color-bg);
    outline: none;
    transition: border-color var(--transition-fast);
    min-height: 36px;
    max-height: 100px;
}

.chat-input:focus {
    border-color: var(--color-primary);
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius);
    border: none;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.chat-send-btn:hover {
    background: var(--color-primary-hover);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
    .chat-bubble {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    }

    .chat-messages {
        max-height: calc(100vh - 160px);
        max-height: calc(100dvh - 160px);
    }
}
