/* ================================================================
   LQIE Chat Widget - Frontend Styles
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
    --lqie-primary: #6c63ff;
    --lqie-bg: #13151c;
    --lqie-surface: #1a1d26;
    --lqie-border: #2a2e3e;
    --lqie-text: #e8eaf0;
    --lqie-text-sec: #7b8198;
    --lqie-teal: #00d4aa;
    --lqie-red: #ff4d6d;
    --lqie-radius: 16px;
    --lqie-shadow: 0 20px 60px rgba(0,0,0,0.45), 0 4px 20px rgba(0,0,0,0.3);
    --lqie-z: 2147483647;
}

/* ── Launcher button ─────────────────────────────────────────────── */
.lqie-launcher {
    position: fixed;
    z-index: var(--lqie-z);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--lqie-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35), 0 0 0 0 rgba(108,99,255,0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    outline: none;
}
.lqie-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,0.4), 0 0 0 8px rgba(108,99,255,0.12);
}
.lqie-launcher:active { transform: scale(0.96); }

.lqie-launcher-icon {
    font-size: 24px !important;
    width: 24px !important;
    height: 24px !important;
    color: #fff;
}

.lqie-launcher .lqie-badge {
    position: absolute;
    top: 0; right: 0;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--lqie-red);
    border: 2px solid #0d0e12;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
}

/* Positioning */
.lqie-pos-bottom-right { bottom: 24px; right: 24px; }
.lqie-pos-bottom-left  { bottom: 24px; left: 24px; }

/* ── Chat window ─────────────────────────────────────────────────── */
.lqie-chat-window {
    position: fixed;
    z-index: var(--lqie-z);
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 600px;
    border-radius: var(--lqie-radius);
    background: var(--lqie-bg);
    border: 1px solid var(--lqie-border);
    box-shadow: var(--lqie-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'DM Sans', sans-serif;
    animation: lqie-open 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

.lqie-chat-window.lqie-pos-bottom-right { bottom: 92px; right: 24px; }
.lqie-chat-window.lqie-pos-bottom-left  { bottom: 92px; left: 24px; transform-origin: bottom left; }

@keyframes lqie-open {
    from { transform: scale(0.88) translateY(12px); opacity: 0; }
    to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

/* ── Header ──────────────────────────────────────────────────────── */
.lqie-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: var(--lqie-surface);
    border-bottom: 1px solid var(--lqie-border);
    flex-shrink: 0;
}

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

.lqie-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--lqie-primary), var(--lqie-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.lqie-chat-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--lqie-text);
    line-height: 1.2;
}

.lqie-chat-status {
    font-size: 11px;
    color: var(--lqie-text-sec);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.lqie-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--lqie-teal);
    animation: lqie-blink 2s ease-in-out infinite;
}
@keyframes lqie-blink {
    0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}

.lqie-close-btn {
    background: none;
    border: none;
    color: var(--lqie-text-sec);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.lqie-close-btn:hover { color: var(--lqie-text); background: rgba(255,255,255,0.05); }

/* ── GDPR notice ─────────────────────────────────────────────────── */
.lqie-gdpr-notice {
    padding: 16px 18px;
    background: rgba(108,99,255,0.08);
    border-bottom: 1px solid var(--lqie-border);
    flex-shrink: 0;
}
.lqie-gdpr-notice p {
    font-size: 12px;
    color: var(--lqie-text-sec);
    margin: 0 0 10px;
    line-height: 1.5;
}
.lqie-gdpr-notice .lqie-btn-primary {
    display: inline-flex;
    align-items: center;
    background: var(--lqie-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: background 0.15s;
}
.lqie-gdpr-notice .lqie-btn-primary:hover { background: #7c74ff; }

/* ── Messages area ───────────────────────────────────────────────── */
.lqie-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    min-height: 200px;
    max-height: 380px;
}

.lqie-messages::-webkit-scrollbar { width: 4px; }
.lqie-messages::-webkit-scrollbar-track { background: transparent; }
.lqie-messages::-webkit-scrollbar-thumb { background: var(--lqie-border); border-radius: 2px; }

/* Messages */
.lqie-msg-wrap {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 90%;
}
.lqie-msg-wrap.lqie-from-user { align-self: flex-end; flex-direction: row-reverse; }
.lqie-msg-wrap.lqie-from-bot  { align-self: flex-start; }

.lqie-msg-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--lqie-primary), var(--lqie-teal));
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.lqie-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    max-width: 100%;
}

.lqie-from-bot .lqie-bubble {
    background: var(--lqie-surface);
    color: var(--lqie-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--lqie-border);
}

.lqie-from-user .lqie-bubble {
    background: var(--lqie-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────────── */
.lqie-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px 0;
    flex-shrink: 0;
}
.lqie-typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--lqie-text-sec);
    animation: lqie-typing-dot 1.4s ease-in-out infinite;
}
.lqie-typing span:nth-child(2) { animation-delay: 0.2s; }
.lqie-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Input row ───────────────────────────────────────────────────── */
.lqie-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--lqie-border);
    background: var(--lqie-surface);
    flex-shrink: 0;
}

.lqie-input {
    flex: 1;
    background: var(--lqie-bg);
    border: 1px solid var(--lqie-border);
    border-radius: 10px;
    color: var(--lqie-text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    padding: 9px 12px;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s;
}
.lqie-input::placeholder { color: var(--lqie-text-sec); }
.lqie-input:focus { border-color: var(--lqie-primary); }
.lqie-input:disabled { opacity: 0.45; cursor: not-allowed; }

.lqie-send-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--lqie-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}
.lqie-send-btn:hover { background: #7c74ff; }
.lqie-send-btn:active { transform: scale(0.93); }
.lqie-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Powered by ──────────────────────────────────────────────────── */
.lqie-powered {
    text-align: center;
    font-size: 10px;
    color: var(--lqie-text-sec);
    opacity: 0.6;
    padding: 5px 0 8px;
    background: var(--lqie-surface);
    flex-shrink: 0;
}

/* ── Inline embed ────────────────────────────────────────────────── */
.lqie-inline-chat {
    background: var(--lqie-bg);
    border: 1px solid var(--lqie-border);
    border-radius: var(--lqie-radius);
    overflow: hidden;
    font-family: 'DM Sans', sans-serif;
}

.lqie-inline-title {
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 700;
    color: var(--lqie-text);
    background: var(--lqie-surface);
    border-bottom: 1px solid var(--lqie-border);
}

.lqie-inline-messages {
    height: 400px;
    max-height: 400px;
}

/* ── Qualification success card ──────────────────────────────────── */
.lqie-qual-card {
    background: rgba(0,212,170,0.08);
    border: 1px solid rgba(0,212,170,0.25);
    border-radius: 10px;
    padding: 14px;
    font-size: 12px;
    color: #00d4aa;
    margin-top: 4px;
}
.lqie-qual-card strong { display: block; margin-bottom: 4px; font-size: 13px; }
.lqie-qual-score {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .lqie-chat-window {
        width: calc(100vw - 16px);
        bottom: 84px !important;
        right: 8px !important;
        left: 8px !important;
        max-height: calc(100dvh - 100px);
    }
    .lqie-launcher { bottom: 16px; right: 16px; }
}
