/*
 * Citra Edukasi - tampilan asisten AI peserta (pasangan assets/js/ce-asisten.js).
 * File statis: boleh diubah langsung tanpa `npm run build`.
 */

.ce-ai-launcher,
.ce-ai-panel {
    --ce-ai-navy: #071452;
    --ce-ai-blue: #1c3fc4;
    --ce-ai-gold: #ffc233;
    --ce-ai-line: #e3e8f4;
    --ce-ai-soft: #f4f6fb;
    --ce-ai-ink: #0f172a;
    --ce-ai-muted: #64748b;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    box-sizing: border-box;
}
.ce-ai-panel *,
.ce-ai-launcher * { box-sizing: border-box; }
/* Halaman website punya gaya globalnya sendiri (huruf, kursor, tautan): di dalam asisten dikembalikan ke bawaan. */
.ce-ai-panel,
.ce-ai-launcher { line-height: 1.5; letter-spacing: normal; text-align: left; text-transform: none; cursor: auto; }
.ce-ai-panel button,
.ce-ai-panel a,
.ce-ai-launcher { cursor: pointer; text-transform: none; letter-spacing: normal; }
.ce-ai-panel textarea { cursor: text; }
.ce-ai-launcher[hidden],
.ce-ai-panel[hidden] { display: none !important; }

/* ---------------------------------------------------------------- tombol pembuka */

.ce-ai-launcher {
    position: fixed;
    right: 22px;
    bottom: max(22px, calc(var(--ce-ai-clear, 0px) + 12px));   /* --ce-ai-clear: tinggi elemen tetap lain di pojok ini (diisi ce-asisten.js) */
    z-index: 1035;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 52px;
    padding: 0 20px 0 16px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #0d2291 0%, var(--ce-ai-navy) 100%);
    color: #fff;
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.1px;
    box-shadow: 0 16px 30px -14px rgba(7, 20, 82, 0.75), 0 2px 6px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.2s ease, opacity 0.2s ease;
}
.ce-ai-launcher svg { flex: 0 0 auto; width: 25px; height: 25px; color: var(--ce-ai-gold); }
.ce-ai-launcher:hover { transform: translateY(-2px); box-shadow: 0 20px 34px -14px rgba(7, 20, 82, 0.85), 0 3px 8px rgba(15, 23, 42, 0.14); }
.ce-ai-launcher:active { transform: scale(0.97); }
.ce-ai-launcher:focus-visible,
.ce-ai-icon:focus-visible,
.ce-ai-send:focus-visible,
.ce-ai-chip:focus-visible { outline: 3px solid var(--ce-ai-gold); outline-offset: 2px; }
.ce-ai-launcher.is-open { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* ---------------------------------------------------------------- panel */

.ce-ai-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1045;   /* di atas bilah navigasi bawah HP (1040), di bawah laci menu, modal, dan dialog (1055+) */
    display: flex;
    flex-direction: column;
    width: 384px;
    max-width: calc(100vw - 32px);
    height: min(600px, calc(100vh - 44px));
    border: 1px solid var(--ce-ai-line);
    border-radius: 20px;
    background: #fff;
    color: var(--ce-ai-ink);
    box-shadow: 0 30px 60px -28px rgba(7, 20, 82, 0.55), 0 8px 20px -12px rgba(15, 23, 42, 0.2);
    overflow: hidden;
    animation: ce-ai-in 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes ce-ai-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.ce-ai-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px 14px 16px;
    background: linear-gradient(135deg, #0d2291 0%, var(--ce-ai-navy) 100%);
    color: #fff;
}
.ce-ai-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--ce-ai-gold);
}
.ce-ai-avatar svg { width: 23px; height: 23px; }
.ce-ai-title { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.ce-ai-title strong { display: block; font-size: 15px; font-weight: 800; }
.ce-ai-title small { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 500; color: rgba(255, 255, 255, 0.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ce-ai-icon {
    padding: 0;
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.ce-ai-icon svg { width: 20px; height: 20px; }
.ce-ai-icon:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------------------------------------------------------------- percakapan */

.ce-ai-list {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px 14px 8px;
    background: var(--ce-ai-soft);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}
.ce-ai-row { display: flex; margin-bottom: 10px; }
.ce-ai-user { justify-content: flex-end; }
.ce-ai-bubble {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 13.8px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.ce-ai-user .ce-ai-bubble { border-bottom-right-radius: 6px; background: var(--ce-ai-blue); color: #fff; }
.ce-ai-bot .ce-ai-bubble { border: 1px solid var(--ce-ai-line); border-bottom-left-radius: 6px; background: #fff; color: var(--ce-ai-ink); }
.ce-ai-bubble p { margin: 0 0 8px; }
.ce-ai-bubble p:last-child,
.ce-ai-bubble ul:last-child,
.ce-ai-bubble ol:last-child { margin-bottom: 0; }
.ce-ai-bubble ul,
.ce-ai-bubble ol { margin: 0 0 8px; padding-left: 20px; }
.ce-ai-bubble li { margin-bottom: 3px; }
.ce-ai-bubble strong { font-weight: 800; }
.ce-ai-bubble code { white-space: pre-wrap; padding: 1px 5px; border-radius: 6px; background: #eef2fb; font: 600 12.5px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; color: #0d2291; }
.ce-ai-bubble a { color: var(--ce-ai-blue); font-weight: 700; text-decoration: underline; }

.ce-ai-typing .ce-ai-bubble { display: inline-flex; align-items: center; gap: 5px; padding: 13px 14px; }
.ce-ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa6c4; animation: ce-ai-dot 1.1s infinite ease-in-out; }
.ce-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ce-ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ce-ai-dot {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.5; }
    35% { transform: translateY(-4px); opacity: 1; }
}

.ce-ai-welcome { margin-bottom: 12px; padding: 14px; border: 1px solid var(--ce-ai-line); border-radius: 16px; background: #fff; font-size: 13.8px; line-height: 1.55; }
.ce-ai-welcome p { margin: 0 0 12px; }
.ce-ai-chips { display: flex; flex-direction: column; gap: 7px; }
.ce-ai-chip {
    padding: 9px 12px;
    border: 1px solid var(--ce-ai-line);
    border-radius: 12px;
    background: var(--ce-ai-soft);
    color: #0d2291;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}
.ce-ai-chip:hover { border-color: #c9d5fb; background: #eaf0ff; transform: translateX(2px); }

.ce-ai-notice { margin: 4px 0 10px; padding: 9px 12px; border-radius: 12px; background: #fff4e0; color: #8a4b00; font-size: 12.8px; font-weight: 600; line-height: 1.45; }

/* Mode tamu: jatah habis -> ajakan menghubungi admin / mendaftar / masuk. */
.ce-ai-limit { margin: 4px 0 10px; padding: 14px; border: 1px solid var(--ce-ai-line); border-radius: 16px; background: #fff; font-size: 13.5px; line-height: 1.5; }
.ce-ai-limit p { margin: 0 0 10px; color: var(--ce-ai-ink); font-weight: 600; }
.ce-ai-ctas { display: flex; flex-wrap: wrap; gap: 8px; }
.ce-ai-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--ce-ai-line);
    border-radius: 12px;
    background: var(--ce-ai-soft);
    color: #0d2291 !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.ce-ai-cta:hover { border-color: #c9d5fb; background: #eaf0ff; }
.ce-ai-cta.is-primary { flex: 1 1 100%; border-color: #0f7a4f; background: #0f7a4f; color: #fff !important; }
.ce-ai-cta.is-primary:hover { background: #0c6642; }

/* ---------------------------------------------------------------- isian */

.ce-ai-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--ce-ai-line); background: #fff; }
.ce-ai-input {
    flex: 1 1 auto;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 13px;
    border: 1px solid var(--ce-ai-line);
    border-radius: 14px;
    background: var(--ce-ai-soft);
    color: var(--ce-ai-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    resize: none;
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.ce-ai-input:focus { border-color: #9fb3f5; background: #fff; box-shadow: 0 0 0 3px rgba(28, 63, 196, 0.12); }
.ce-ai-input:disabled { color: var(--ce-ai-muted); cursor: not-allowed; }
.ce-ai-send {
    padding: 0;
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    height: 42px;
    border: 0;
    border-radius: 14px;
    background: var(--ce-ai-gold);
    color: var(--ce-ai-navy);
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
.ce-ai-send svg { width: 20px; height: 20px; }
.ce-ai-send:hover { filter: brightness(1.05); transform: translateY(-1px); }
.ce-ai-send:active { transform: scale(0.95); }
.ce-ai-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.ce-ai-note { margin: 0; padding: 0 14px 10px; background: #fff; color: var(--ce-ai-muted); font-size: 11.5px; font-weight: 500; text-align: center; min-height: 26px; }

/* ---------------------------------------------------------------- HP */

@media (max-width: 575.98px) {
    .ce-ai-launcher { right: 14px; bottom: max(14px, calc(var(--ce-ai-clear, 0px) + 12px)); width: 54px; height: 54px; padding: 0; justify-content: center; }
    .ce-ai-launcher span { display: none; }
    .ce-ai-launcher svg { width: 28px; height: 28px; }
    .ce-ai-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        height: 86vh;
        height: 86dvh;
        border-width: 1px 0 0;
        border-radius: 20px 20px 0 0;
    }
    .ce-ai-bubble { font-size: 14.2px; }
    .ce-ai-input { font-size: 16px; }   /* di bawah 16px, iPhone memperbesar halaman saat mengetik */
}

@media (prefers-reduced-motion: reduce) {
    .ce-ai-panel,
    .ce-ai-typing span { animation: none; }
    .ce-ai-launcher,
    .ce-ai-chip,
    .ce-ai-send { transition: none; }
}
