/* ==========================================================================
   07-moxi — Moxi, asisten LMS (partials/moxi.blade.php).
   Design read: B · peserta yang sedang belajar, butuh jawaban cepat tanpa pindah halaman ·
   satu pekerjaan: tanya soal Maxy · elemen berani: Moxi yang hidup saat panel dibuka · dial 3/3/4.
   Moxi direkam di latar krem (--mx-moxi-paper), jadi ia selalu duduk di bidang krem itu, tidak di atas putih.
   Gerak: hanya transform/opacity, kurva --mx-ease. Reduced motion: animasi Moxi tidak dimuat sama sekali.
   ========================================================================== */
:root {
    --mx-moxi-paper: #F3EEE4;   /* latar video Moxi (sama dengan MwColors.paper di app Warriors) */
    --mx-moxi-line: #E4DCCB;
}

/* Website publik tidak memuat 01-tokens (supaya Bootstrap halaman publik tidak ikut berubah),
   jadi token yang dipakai Moxi disalin ke dalam .moxi saja. Nilainya sama persis dengan 01-tokens. */
.moxi {
    --mx-yellow: #F5A623; --mx-yellow-pale: #FEF4E0; --mx-gold-ink: #A16207;
    --mx-navy: #2A3164; --mx-navy-deep: #1A2049; --mx-navy-pale: #EDEFF8;
    --mx-paper: #FFFFFF; --mx-bg: #F7F8FB; --mx-bg-2: #EEF1F8; --mx-line: #E3E8F2; --mx-line-2: #CBD3E6;
    --mx-ink: #141A33; --mx-ink-2: #4A5478; --mx-ink-3: #6B7599;
    --mx-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mx-font-display: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mx-r-sm: 10px; --mx-r: 14px; --mx-r-lg: 18px; --mx-r-pill: 999px;
    --mx-sh: 0 4px 16px -4px rgba(26, 32, 73, .10), 0 0 0 1px rgba(26, 32, 73, .05);
    --mx-sh-lg: 0 24px 56px -20px rgba(26, 32, 73, .22), 0 0 0 1px rgba(26, 32, 73, .06);
    --mx-focus: 0 0 0 3px rgba(42, 49, 100, .30);
    --mx-ease: cubic-bezier(.16, 1, .3, 1); --mx-t-fast: 140ms; --mx-t: 220ms;
}
.moxi *, .moxi *::before, .moxi *::after { box-sizing: border-box; }

/* --- tombol pemanggil ---------------------------------------------------- */
.moxi-launch {
    position: fixed; right: 20px; bottom: 20px; z-index: 1040;
    display: flex; align-items: center; gap: 10px;
    border: 0; padding: 0; background: none; cursor: pointer;
    transition: transform var(--mx-t) var(--mx-ease), opacity var(--mx-t) var(--mx-ease);
}
.moxi-launch:focus-visible { outline: none; }
.moxi-launch:focus-visible .moxi-launch__face { box-shadow: var(--mx-focus), var(--mx-sh); }
.moxi-launch__face {   /* bulat, diperbesar ke kepala + bandana (aset 328×400); cincin putih + bayangan supaya krem tidak melebur */
    width: 84px; height: 84px; border-radius: 50%; overflow: hidden; flex: none;
    background: var(--mx-moxi-paper); box-shadow: var(--mx-sh), 0 0 0 1px rgba(16, 24, 40, .08); border: 3px solid #fff;
    transition: transform var(--mx-t) var(--mx-ease);
}
.moxi-launch:hover .moxi-launch__face { transform: translateY(-2px) scale(1.04); }
.moxi-launch:active .moxi-launch__face { transform: scale(.96); }
/* potongan sumber x 44–284, y 95–335: kepala di sepertiga atas lingkaran */
.moxi-launch__face img, .moxi-avatar img { width: 136.7%; max-width: none; height: auto; margin: -39.6% 0 0 -18.3%; display: block; }
.moxi-launch__tip {
    order: -1; background: var(--mx-paper); color: var(--mx-ink); border-radius: var(--mx-r-pill);
    padding: 8px 14px; font: 600 13px/1.2 var(--mx-font); box-shadow: var(--mx-sh); white-space: nowrap;
    opacity: 0; transform: translateX(6px); pointer-events: none;
    transition: opacity var(--mx-t) var(--mx-ease), transform var(--mx-t) var(--mx-ease);
}
.moxi-launch:hover .moxi-launch__tip, .moxi-launch.is-hello .moxi-launch__tip { opacity: 1; transform: none; }
.moxi.is-open .moxi-launch { opacity: 0; transform: scale(.8); pointer-events: none; }
/* bar bawah halaman modul / simpan profil */
body:has(.mx-lesson-nav) .moxi-launch, body:has(.mx-savebar) .moxi-launch { bottom: 92px; }

/* --- panel --------------------------------------------------------------- */
.moxi-panel {
    position: fixed; right: 20px; bottom: 20px; z-index: 1045;
    width: 392px; height: min(620px, calc(100vh - 40px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--mx-paper); border-radius: var(--mx-r-lg); box-shadow: var(--mx-sh-lg);
    font-family: var(--mx-font); color: var(--mx-ink);
    opacity: 0; transform: translateY(12px) scale(.98); transform-origin: 100% 100%; visibility: hidden;
    transition: opacity var(--mx-t) var(--mx-ease), transform var(--mx-t) var(--mx-ease), visibility 0s linear var(--mx-t);
}
.moxi.is-open .moxi-panel { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }

.moxi-head {
    display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px;
    border-bottom: 1px solid var(--mx-line); flex: none;
}
.moxi-avatar { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--mx-moxi-paper); flex: none; box-shadow: 0 0 0 1px rgba(16, 24, 40, .08); }
.moxi-head__text { min-width: 0; flex: 1; }
.moxi-head__name { margin: 0; font: 700 16px/1.2 var(--mx-font-display); color: var(--mx-ink); }
.moxi-head__sub { margin: 2px 0 0; font-size: 12.5px; line-height: 1.3; color: var(--mx-ink-3); }
.moxi-icon-btn {
    width: 44px; height: 44px; border: 0; border-radius: var(--mx-r-sm); background: none; color: var(--mx-ink-2);
    display: grid; place-items: center; font-size: 18px; flex: none; cursor: pointer;
    transition: background-color var(--mx-t-fast) var(--mx-ease), color var(--mx-t-fast) var(--mx-ease);
}
.moxi-icon-btn:hover { background: var(--mx-bg-2); color: var(--mx-ink); }
.moxi-icon-btn:focus-visible { outline: none; box-shadow: var(--mx-focus); }

/* --- isi percakapan ------------------------------------------------------ */
.moxi-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; scroll-behavior: smooth; overscroll-behavior: contain; }

/* sambutan: momen Moxi besar */
.moxi-hello { text-align: center; padding: 4px 6px 8px; }
.moxi-hello__stage {
    width: 148px; height: 180px; margin: 0 auto 14px; border-radius: var(--mx-r-lg); overflow: hidden;
    background: var(--mx-moxi-paper);
}
.moxi-hello__stage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.moxi-hello h3 { margin: 0 0 6px; font: 700 20px/1.25 var(--mx-font-display); color: var(--mx-ink); }
.moxi-hello p { margin: 0 auto 16px; max-width: 290px; font-size: 14px; line-height: 1.5; color: var(--mx-ink-2); }
.moxi-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.moxi-chip {
    border: 1px solid var(--mx-line-2); background: var(--mx-paper); color: var(--mx-navy);
    border-radius: var(--mx-r-pill); padding: 9px 14px; min-height: 40px; font: 600 13px/1.2 var(--mx-font); cursor: pointer;
    transition: background-color var(--mx-t-fast) var(--mx-ease), border-color var(--mx-t-fast) var(--mx-ease);
}
.moxi-chip:hover { background: var(--mx-navy-pale); border-color: var(--mx-navy-pale); }
.moxi-chip:focus-visible { outline: none; box-shadow: var(--mx-focus); }

.moxi-msg { display: flex; margin: 0 0 12px; animation: moxi-in var(--mx-t) var(--mx-ease) both; }
.moxi-msg--me { justify-content: flex-end; }
.moxi-bubble { max-width: 86%; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.moxi-msg--me .moxi-bubble {
    background: var(--mx-navy); color: var(--mx-paper);   /* 11.6:1 */
    padding: 9px 14px; border-radius: var(--mx-r) var(--mx-r) 4px var(--mx-r); white-space: pre-wrap;
}
.moxi-msg--bot .moxi-bubble {
    background: var(--mx-bg); border: 1px solid var(--mx-line); color: var(--mx-ink);
    padding: 11px 14px; border-radius: 4px var(--mx-r) var(--mx-r) var(--mx-r);
}
.moxi-bubble p { margin: 0 0 8px; }
.moxi-bubble p:last-child, .moxi-bubble ul:last-child, .moxi-bubble ol:last-child { margin-bottom: 0; }
.moxi-bubble ul, .moxi-bubble ol { margin: 0 0 8px; padding-left: 0; list-style: none; }
.moxi-bubble li { position: relative; padding: 5px 0 5px 18px; border-top: 1px solid var(--mx-line); }
.moxi-bubble li:first-child { border-top: 0; }
.moxi-bubble ul > li::before { content: ""; position: absolute; left: 3px; top: 13px; width: 6px; height: 6px; border-radius: 50%; background: var(--mx-yellow); }
.moxi-bubble ol { counter-reset: moxi; }
.moxi-bubble ol > li { counter-increment: moxi; padding-left: 26px; }
.moxi-bubble ol > li::before {
    content: counter(moxi); position: absolute; left: 0; top: 5px; width: 18px; height: 18px; border-radius: 50%;
    background: var(--mx-yellow-pale); color: var(--mx-gold-ink); font: 700 11px/18px var(--mx-font); text-align: center;
}
.moxi-bubble strong { font-weight: 700; color: var(--mx-navy-deep); }
.moxi-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.moxi-link {
    display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 7px 12px;
    border-radius: var(--mx-r-pill); background: var(--mx-paper); border: 1px solid var(--mx-line-2);
    color: var(--mx-navy); font: 600 13px/1.2 var(--mx-font); text-decoration: none;
    transition: background-color var(--mx-t-fast) var(--mx-ease), border-color var(--mx-t-fast) var(--mx-ease);
}
.moxi-link:hover { background: var(--mx-navy-pale); border-color: var(--mx-navy-pale); color: var(--mx-navy-deep); }
.moxi-link:focus-visible { outline: none; box-shadow: var(--mx-focus); }

.moxi-typing { display: inline-flex; align-items: center; gap: 8px; color: var(--mx-ink-2); font-size: 13.5px; }
.moxi-dots { display: inline-flex; gap: 4px; }
.moxi-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--mx-ink-3); animation: moxi-dot 1s var(--mx-ease) infinite; }
.moxi-dots i:nth-child(2) { animation-delay: .15s; }
.moxi-dots i:nth-child(3) { animation-delay: .3s; }

/* --- kolom ketik --------------------------------------------------------- */
.moxi-foot { flex: none; padding: 10px 12px 12px; border-top: 1px solid var(--mx-line); background: var(--mx-paper); }
.moxi-form { display: flex; align-items: flex-end; gap: 8px; background: var(--mx-bg); border: 1px solid var(--mx-line); border-radius: var(--mx-r); padding: 4px 4px 4px 12px; transition: border-color var(--mx-t-fast) var(--mx-ease), box-shadow var(--mx-t-fast) var(--mx-ease); }
.moxi-form:focus-within { border-color: var(--mx-navy); box-shadow: var(--mx-focus); }
.moxi-input {
    flex: 1; border: 0; background: none; resize: none; outline: none; padding: 9px 0; max-height: 108px;
    font: 400 14px/1.45 var(--mx-font); color: var(--mx-ink);
}
/* gaya input bawaan LMS (border + cincin fokus) dimatikan: fokus sudah ditandai oleh .moxi-form */
.moxi-input, .moxi-input:focus, .moxi-input:focus-visible { border: 0 !important; box-shadow: none !important; outline: none !important; background: none !important; }
.moxi-input::placeholder { color: var(--mx-ink-3); }
.moxi-send {
    width: 40px; height: 40px; border: 0; border-radius: var(--mx-r-sm); flex: none; cursor: pointer;
    background: var(--mx-yellow); color: var(--mx-navy-deep); display: grid; place-items: center; font-size: 17px;   /* ikon navy di kuning ≈ 9:1 */
    transition: transform var(--mx-t-fast) var(--mx-ease), opacity var(--mx-t-fast) var(--mx-ease);
}
.moxi-send:hover { transform: translateY(-1px); }
.moxi-send:disabled { opacity: .45; cursor: default; transform: none; }
.moxi-send:focus-visible { outline: none; box-shadow: var(--mx-focus); }

/* --- kartu program (nama, harga, link dari DB) ---------------------------- */
.moxi-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.moxi-card {
    display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; min-height: 64px;
    background: var(--mx-paper); border: 1px solid var(--mx-line); border-radius: var(--mx-r);
    color: var(--mx-ink); text-decoration: none;
    transition: border-color var(--mx-t-fast) var(--mx-ease), transform var(--mx-t-fast) var(--mx-ease), box-shadow var(--mx-t-fast) var(--mx-ease);
}
.moxi-card:hover { border-color: var(--mx-line-2); box-shadow: var(--mx-sh); transform: translateY(-1px); color: var(--mx-ink); }
.moxi-card:focus-visible { outline: none; box-shadow: var(--mx-focus); }
.moxi-card__thumb {
    width: 48px; height: 48px; border-radius: var(--mx-r-sm); overflow: hidden; flex: none;
    background: var(--mx-navy-pale); color: var(--mx-navy); display: grid; place-items: center; font-size: 20px;
}
.moxi-card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.moxi-card__body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.moxi-card__type { font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--mx-ink-3); }
.moxi-card__name { font: 600 13.5px/1.3 var(--mx-font); color: var(--mx-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.moxi-card__price { font: 700 13px/1.3 var(--mx-font); color: var(--mx-gold-ink); font-variant-numeric: tabular-nums; }   /* 5.0:1 */
.moxi-card__go { color: var(--mx-ink-3); font-size: 15px; flex: none; transition: transform var(--mx-t-fast) var(--mx-ease), color var(--mx-t-fast) var(--mx-ease); }
.moxi-card:hover .moxi-card__go { transform: translateX(2px); color: var(--mx-navy); }

/* --- website publik: Moxi di pojok kanan bawah seperti di LMS; tombol WhatsApp (floatbutton) duduk di atasnya --- */
.moxi--public .moxi-launch { right: 20px; bottom: 20px; }
.moxi--public .moxi-panel { z-index: 1050; }

@keyframes moxi-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes moxi-dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* --- HP: panel jadi layar penuh ----------------------------------------- */
@media (max-width: 575.98px) {
    .moxi--public .moxi-launch { right: 14px; bottom: 14px; }
    .moxi-launch { right: 14px; bottom: 14px; }
    .moxi-launch__face { width: 72px; height: 72px; }
    .moxi-launch__tip { display: none; }
    body:has(.mx-lesson-nav) .moxi-launch, body:has(.mx-savebar) .moxi-launch { bottom: 84px; }
    .moxi-panel { inset: 0; width: auto; height: auto; border-radius: 0; transform: translateY(16px); }
    .moxi-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .moxi-launch, .moxi-launch__face, .moxi-launch__tip, .moxi-panel, .moxi-send, .moxi-card, .moxi-card__go { transition: none; }
    .moxi-msg { animation: none; }
    .moxi-dots i { animation: none; opacity: .7; }
    .moxi-log { scroll-behavior: auto; }
}
