/**
 * Chat Widget Styles
 * AI Assistant floating chat window
 */

/* ========================================
   FLOATING BUTTON
   ======================================== */
.chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-dark));
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    z-index: 999;
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-widget-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(139, 92, 246, 0.55);
}

/* ========================================
   CHAT WINDOW
   ======================================== */
.chat-window {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.chat-window.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ========================================
   HEADER
   ======================================== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}
.chat-title-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}
.chat-header-actions {
    display: flex;
    gap: 4px;
}
.chat-header-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.chat-header-btn:hover {
    background: var(--bg-card-alt);
    color: var(--text-primary);
}

/* ========================================
   MESSAGES
   ======================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
}

.chat-message {
    max-width: 88%;
    animation: chatFadeIn 0.2s ease-out;
}
.chat-message.user {
    align-self: flex-end;
}
.chat-message.ai,
.chat-message.welcome {
    align-self: flex-start;
}

.chat-message .message-content {
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-message.user .message-content {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-dark));
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-message.ai .message-content {
    background: var(--bg-card-alt);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-message.welcome .message-content {
    background: transparent;
    padding: 20px 10px;
}

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

/* ========================================
   TYPING INDICATOR
   ======================================== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-card-alt);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 120px;
    animation: chatFadeIn 0.2s ease-out;
}
.typing-dots {
    display: flex;
    gap: 4px;
}
.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
.typing-text {
    font-size: 11px;
    color: var(--text-muted);
    display: none;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ========================================
   INPUT AREA
   ======================================== */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 6px 8px 6px 14px;
    transition: border-color 0.15s;
}
.chat-input-wrapper:focus-within {
    border-color: var(--accent-purple);
}
.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.4;
    resize: none;
    max-height: 80px;
    font-family: inherit;
}
.chat-input::placeholder {
    color: var(--text-muted);
}
.chat-send-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: var(--accent-purple);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: background 0.15s;
}
.chat-send-btn:hover {
    background: var(--accent-purple-dark);
}

/* ========================================
   CHAT TABLE (query results)
   ======================================== */
.chat-table-wrapper {
    margin-top: 8px;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}
.chat-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}
.chat-table th {
    background: var(--bg-primary);
    color: var(--text-secondary);
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
}
.chat-table td {
    padding: 5px 8px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
    white-space: nowrap;
}
.chat-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.chat-table td.more {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 6px;
}
.chat-table tr:last-child td {
    border-bottom: none;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    .chat-window {
        right: 8px;
        left: 8px;
        bottom: 80px;
        width: auto;
        max-height: 70vh;
    }
    .chat-widget-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}
