/* =====================================================================
   AIXplore AI Chatbot widget
   Self-contained, scoped styles (all selectors namespaced with .aixc-).
   ===================================================================== */

#aixplore-chatbot {
    --aixc-accent: #00d4ff;
    --aixc-accent-2: #6a5cff;
    --aixc-bg: #12161c;
    --aixc-surface: #1a1f26;
    --aixc-surface-2: #222833;
    --aixc-border: rgba(255, 255, 255, 0.08);
    --aixc-text: #e8ecf1;
    --aixc-text-muted: #93a0b0;
    --aixc-radius: 16px;
    --aixc-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --aixc-z: 2147483000;
}

/* ---- Launcher button --------------------------------------------- */
.aixc-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: var(--aixc-z);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #06121a;
    background: linear-gradient(135deg, var(--aixc-accent), var(--aixc-accent-2));
    box-shadow: var(--aixc-shadow);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.aixc-launcher:hover { transform: translateY(-2px) scale(1.03); }
.aixc-launcher:focus-visible { outline: 3px solid rgba(0, 212, 255, 0.5); outline-offset: 2px; }
.aixc-launcher svg { width: 26px; height: 26px; margin: auto; display: block; }
.aixc-launcher.aixc-hidden { transform: scale(0); opacity: 0; pointer-events: none; }

/* ---- Panel ------------------------------------------------------- */
.aixc-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: var(--aixc-z);
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 40px);
    background: var(--aixc-bg);
    border: 1px solid var(--aixc-border);
    border-radius: var(--aixc-radius);
    box-shadow: var(--aixc-shadow);
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.aixc-panel.aixc-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ---- Header ------------------------------------------------------ */
.aixc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.16), rgba(106, 92, 255, 0.16));
    border-bottom: 1px solid var(--aixc-border);
}
.aixc-header-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--aixc-accent), var(--aixc-accent-2));
    color: #06121a;
    flex-shrink: 0;
}
.aixc-header-avatar svg { width: 20px; height: 20px; }
.aixc-header-info { display: flex; flex-direction: column; line-height: 1.2; }
.aixc-header-title { color: var(--aixc-text); font-weight: 700; font-size: 0.95rem; }
.aixc-header-sub { color: var(--aixc-text-muted); font-size: 0.72rem; }
.aixc-close {
    margin-left: auto;
    background: transparent; border: none; cursor: pointer;
    color: var(--aixc-text-muted);
    width: 32px; height: 32px; border-radius: 8px;
    display: grid; place-items: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.aixc-close:hover { background: rgba(255,255,255,0.06); color: var(--aixc-text); }
.aixc-close svg { width: 18px; height: 18px; }

/* ---- Messages ---------------------------------------------------- */
.aixc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--aixc-surface-2) transparent;
}
.aixc-messages::-webkit-scrollbar { width: 8px; }
.aixc-messages::-webkit-scrollbar-thumb { background: var(--aixc-surface-2); border-radius: 8px; }

.aixc-msg { display: flex; max-width: 100%; }
.aixc-msg-user { justify-content: flex-end; }
.aixc-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    max-width: 85%;
}
.aixc-msg-user .aixc-bubble {
    background: linear-gradient(135deg, var(--aixc-accent), var(--aixc-accent-2));
    color: #06121a;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}
.aixc-msg-bot .aixc-bubble {
    background: var(--aixc-surface);
    color: var(--aixc-text);
    border: 1px solid var(--aixc-border);
    border-bottom-left-radius: 4px;
}
.aixc-bubble p { margin: 0 0 8px; }
.aixc-bubble p:last-child { margin-bottom: 0; }
.aixc-bubble ul { margin: 6px 0; padding-left: 18px; }
.aixc-bubble li { margin: 3px 0; }
.aixc-bubble strong { color: #fff; font-weight: 700; }
.aixc-bubble a { color: var(--aixc-accent); }

/* ---- Related content cards --------------------------------------- */
.aixc-related { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.aixc-related-heading {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--aixc-text-muted);
    margin: 2px 0;
}
.aixc-card {
    display: block;
    text-decoration: none;
    background: var(--aixc-surface-2);
    border: 1px solid var(--aixc-border);
    border-radius: 10px;
    padding: 9px 11px;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.aixc-card:hover { border-color: var(--aixc-accent); transform: translateX(2px); }
.aixc-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.aixc-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 999px;
    color: var(--aixc-accent);
    background: rgba(0, 212, 255, 0.12);
    white-space: nowrap;
}
.aixc-card-title { color: var(--aixc-text); font-size: 0.83rem; font-weight: 600; line-height: 1.3; }
.aixc-card-snippet { color: var(--aixc-text-muted); font-size: 0.75rem; line-height: 1.4; margin-top: 2px; }

/* ---- Typing indicator -------------------------------------------- */
.aixc-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.aixc-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--aixc-text-muted);
    animation: aixc-bounce 1.2s infinite ease-in-out;
}
.aixc-typing span:nth-child(2) { animation-delay: 0.15s; }
.aixc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aixc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---- Suggestions ------------------------------------------------- */
.aixc-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.aixc-suggestion {
    background: var(--aixc-surface);
    border: 1px solid var(--aixc-border);
    color: var(--aixc-text);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.aixc-suggestion:hover { border-color: var(--aixc-accent); color: var(--aixc-accent); }

/* ---- Input ------------------------------------------------------- */
.aixc-input-area {
    border-top: 1px solid var(--aixc-border);
    padding: 10px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--aixc-surface);
}
.aixc-input {
    flex: 1;
    resize: none;
    max-height: 110px;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--aixc-border);
    background: var(--aixc-bg);
    color: var(--aixc-text);
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.15s ease;
}
.aixc-input:focus { border-color: var(--aixc-accent); }
.aixc-input::placeholder { color: var(--aixc-text-muted); }
.aixc-send {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border: none; border-radius: 12px; cursor: pointer;
    background: linear-gradient(135deg, var(--aixc-accent), var(--aixc-accent-2));
    color: #06121a;
    display: grid; place-items: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.aixc-send:hover { transform: scale(1.05); }
.aixc-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.aixc-send svg { width: 19px; height: 19px; }

.aixc-footnote { text-align: center; font-size: 0.66rem; color: var(--aixc-text-muted); padding: 0 10px 8px; background: var(--aixc-surface); }

/* ---- Mobile ------------------------------------------------------ */
@media (max-width: 480px) {
    .aixc-panel {
        right: 0; bottom: 0;
        width: 100vw; max-width: 100vw;
        height: 88vh; max-height: 88vh;
        border-radius: 16px 16px 0 0;
    }
    .aixc-launcher { right: 16px; bottom: 16px; }
}

/* ---- Reduced motion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .aixc-panel, .aixc-launcher, .aixc-card, .aixc-send { transition: none; }
    .aixc-typing span { animation: none; }
}
