/**
 * FlashGL AI Chat Widget Styles — Enhanced
 *
 * Floating chat bubble + expandable conversation panel.
 * Includes CTA action buttons, markdown links, typing indicator.
 * Dark-theme compatible — uses CSS custom properties from base.css.
 *
 * @package FlashGL
 */

/* ── Chat Bubble ──────────────────────────────────────────── */
#flashgl-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99990;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--flashgl-primary, #1A2B8C);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(26,43,140,0.35);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
}
#flashgl-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(26,43,140,0.45);
}
#flashgl-chat-bubble.flashgl-chat-bubble--hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* ── Chat Panel ───────────────────────────────────────────── */
#flashgl-chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99991;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18), 0 0 0 1px rgba(26,43,140,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
#flashgl-chat-panel.flashgl-chat--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Chat Header ──────────────────────────────────────────── */
#flashgl-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--flashgl-primary, #1A2B8C);
    color: #fff;
    flex-shrink: 0;
}
#flashgl-chat-title {
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
#flashgl-chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
#flashgl-chat-close:hover {
    color: #fff;
}

/* ── Messages Container ───────────────────────────────────── */
#flashgl-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #F8FAFC;
}

/* ── Message Bubbles ──────────────────────────────────────── */
.flashgl-chat-msg {
    max-width: 88%;
    word-wrap: break-word;
}
.flashgl-chat-msg__text {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* User messages */
.flashgl-chat-msg--user {
    align-self: flex-end;
}
.flashgl-chat-msg--user .flashgl-chat-msg__text {
    background: var(--flashgl-primary, #1A2B8C);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Bot messages */
.flashgl-chat-msg--bot {
    align-self: flex-start;
}
.flashgl-chat-msg--bot .flashgl-chat-msg__text {
    background: #fff;
    color: #1F2937;
    border: 1px solid rgba(26,43,140,0.06);
    border-bottom-left-radius: 4px;
}

/* ── Typing Indicator ─────────────────────────────────────── */
.flashgl-chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.flashgl-chat-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94A3B8;
    animation: flashgl-typing-bounce 1.2s ease-in-out infinite;
}
.flashgl-chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.flashgl-chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

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

/* ── Quick Reply Chips ────────────────────────────────────── */
#flashgl-chat-quick-replies {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 14px 8px;
    background: #F8FAFC;
}
.flashgl-chat-chip {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(26,43,140,0.15);
    background: #fff;
    color: var(--flashgl-primary, #1A2B8C);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.flashgl-chat-chip:hover {
    background: rgba(26,43,140,0.06);
    border-color: rgba(26,43,140,0.3);
}

/* ── Input Area ───────────────────────────────────────────── */
#flashgl-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #E5E7EB;
    background: #fff;
    flex-shrink: 0;
}
#flashgl-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #D1D5DB;
    border-radius: 24px;
    font-size: 0.8125rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    background: #F9FAFB;
}
#flashgl-chat-input:focus {
    border-color: var(--flashgl-primary, #1A2B8C);
    background: #fff;
}
#flashgl-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--flashgl-accent, #D00020);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}
#flashgl-chat-send:hover {
    background: #A30018;
    transform: scale(1.05);
}

/* ── Chat Links (markdown-lite) ──────────────────────────── */
.flashgl-chat-link {
    color: var(--flashgl-primary, #1A2B8C);
    text-decoration: underline;
    text-decoration-color: rgba(26,43,140,0.3);
    transition: text-decoration-color 0.15s;
}
.flashgl-chat-link:hover {
    text-decoration-color: var(--flashgl-primary, #1A2B8C);
}

/* ── CTA Action Buttons ──────────────────────────────────── */
.flashgl-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.flashgl-chat-cta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(26,43,140,0.2);
    background: #fff;
    color: var(--flashgl-primary, #1A2B8C);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    cursor: pointer;
    white-space: nowrap;
}
.flashgl-chat-cta:hover {
    background: rgba(26,43,140,0.06);
    border-color: rgba(26,43,140,0.4);
    transform: translateY(-1px);
}
.flashgl-chat-cta--accent {
    background: var(--flashgl-accent, #D00020);
    color: #fff;
    border-color: var(--flashgl-accent, #D00020);
}
.flashgl-chat-cta--accent:hover {
    background: #A30018;
    border-color: #A30018;
    color: #fff;
}

/* ── Mobile Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    .mobile-quickbar { transition: opacity 0.2s, visibility 0.2s; }
    body.flashgl-chat-active .mobile-quickbar {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
    #flashgl-chat-bubble {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        width: 48px;
        height: 48px;
    }
    #flashgl-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 75vh;
        max-height: 75vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(26,43,140,0.06);
        transform: translateY(20px) scale(1);
    }
    #flashgl-chat-panel.flashgl-chat--open {
        transform: translateY(0) scale(1);
    }
    .flashgl-chat-actions {
        flex-direction: column;
    }
    .flashgl-chat-cta {
        width: 100%;
        justify-content: center;
    }
}
@media (max-width: 480px) {
    #flashgl-chat-panel {
        height: 80vh;
        max-height: 80vh;
    }
}

/* ── Input Buttons (Voice & Image) ──────────────────────── */
.flashgl-chat-input-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #F3F4F6;
    color: #6B7280;
    border: 1px solid #E5E7EB;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.flashgl-chat-input-btn:hover {
    background: #E5E7EB;
    color: var(--flashgl-primary, #1A2B8C);
    border-color: rgba(26,43,140,0.3);
}
.flashgl-chat-input-btn.flashgl-chat-active {
    background: var(--flashgl-primary, #1A2B8C);
    color: #fff;
    border-color: var(--flashgl-primary, #1A2B8C);
    animation: flashgl-pulse 1.5s ease-in-out infinite;
}

@keyframes flashgl-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ── Streaming Cursor ───────────────────────────────────── */
.flashgl-chat-cursor {
    display: inline-block;
    animation: flashgl-blink 1s step-end infinite;
    font-weight: 100;
    color: var(--flashgl-primary, #1A2B8C);
}

@keyframes flashgl-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
