/*
 * Ilustrasi percakapan Nexus AI di hero landing page Tukar Tambah (bukan data sungguhan).
 * Markup: resources/views/frontend/tukar_tambah/_hero_chat_message.blade.php. Isi: TukarTambahLandingChatDemo.
 * Gerak (pesan muncul bergantian, ganti skenario, ulang): landing-chat.js. Memakai variabel dan keyframes dari landing.css.
 * Semua gerak hanya transform/opacity. Tanpa JavaScript (atau prefers-reduced-motion) skenario pertama tampil utuh dan diam.
 */

/* ---------- panggung ---------- */
.ttl-stage { position: relative; display: grid; justify-items: center; align-content: center; gap: 18px; min-height: 640px; padding: 66px 0 6px; }
.ttl-stage::before {
    content: ''; position: absolute; z-index: 0; width: 86%; aspect-ratio: 1; top: 50%; left: 50%; margin: -43% 0 0 -43%; border-radius: 50%;
    background: radial-gradient(closest-side, rgba(56, 182, 235, .42), rgba(56, 182, 235, 0) 72%);
    animation: ttl-glow 7s ease-in-out infinite alternate;
}
@keyframes ttl-glow { to { transform: scale(1.12); opacity: .75; } }

/* ---------- kartu chat ---------- */
.ttl-chat {
    position: relative; z-index: 1; width: min(100%, 440px); height: 540px; display: flex; flex-direction: column; border-radius: 30px;
    background: #fff; color: var(--ttl-ink); overflow: hidden; will-change: transform;
    box-shadow: 0 50px 90px rgba(2, 12, 28, .55), 0 0 0 1px rgba(255, 255, 255, .55) inset, 0 0 0 7px rgba(255, 255, 255, .08);
    transform: perspective(1400px) rotateY(-6deg) rotateX(2deg); animation: ttl-float 8s ease-in-out infinite;
}
@keyframes ttl-float { 50% { transform: perspective(1400px) rotateY(-6deg) rotateX(2deg) translateY(-12px); } }

.ttl-chat__head { flex: none; display: flex; align-items: center; gap: 12px; padding: 16px 18px; color: #fff; background: linear-gradient(120deg, #0F76A8, var(--ttl-blue) 55%, #1BA5E6); }
.ttl-chat__avatar { position: relative; flex: none; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 19px; background: rgba(255, 255, 255, .2); }
.ttl-chat__online { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; background: #3DDC84; box-shadow: 0 0 0 3px #1596D2; }
.ttl-chat__online::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: #3DDC84; animation: ttl-online 2s ease-out infinite; }
@keyframes ttl-online { from { transform: scale(1); opacity: .7; } to { transform: scale(2.6); opacity: 0; } }
.ttl-chat__who { min-width: 0; }
.ttl-chat__title { font-weight: 700; line-height: 1.15; }
.ttl-chat__status { font-size: 12px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttl-chat__label {
    margin-left: auto; flex: none; max-width: 46%; padding: 6px 12px; border-radius: 99px; font-size: 11px; font-weight: 600; line-height: 1.25; text-align: center;
    background: rgba(255, 255, 255, .18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}
.ttl-chat__label span { display: block; transition: opacity .25s ease, transform .25s ease; }
.ttl-chat__label.is-swap span { opacity: 0; transform: translateY(-5px); }

/* area pesan: tanpa JS pesan terakhir menempel di bawah; dengan JS .track digeser (translate) supaya mulus */
.ttl-chat__feed { position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: flex-end; background: linear-gradient(180deg, #F4F8FC, #EDF3F9); transition: opacity .5s ease; }
.ttl-chat.is-live .ttl-chat__feed { align-items: flex-start; }
.ttl-chat.is-leaving .ttl-chat__feed { opacity: 0; }
.ttl-chat__feed::before { content: ''; position: absolute; z-index: 2; inset: 0 0 auto 0; height: 36px; pointer-events: none; background: linear-gradient(#F4F8FC, rgba(244, 248, 252, 0)); }
.ttl-chat__track { width: 100%; display: flex; flex-direction: column; gap: 10px; padding: 20px 18px 18px; transition: transform .75s var(--ttl-ease); will-change: transform; }

.ttl-chat__foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; border-top: 1px solid #E6EEF6; }
.ttl-chat__input { flex: 1; padding: 10px 16px; border-radius: 99px; background: #F1F5F9; color: #94A3B8; font-size: 13px; }
.ttl-chat__send { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; color: #fff; background: var(--ttl-blue); box-shadow: 0 6px 14px rgba(20, 139, 198, .35); }

/* penanda skenario (satu titik per skenario) */
.ttl-chat__dots { position: relative; z-index: 1; display: flex; gap: 8px; }
.ttl-chat__dots i { width: 8px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .3); transition: width .45s var(--ttl-ease), background .45s ease; }
.ttl-chat__dots i.is-on { width: 28px; background: var(--ttl-yellow); }

/* ---------- gelembung ---------- */
.ttl-bub { position: relative; max-width: 86%; padding: 11px 14px; border-radius: 18px; font-size: 13.5px; line-height: 1.5; }
.ttl-bub p { margin: 0; }
.ttl-bub--ai { align-self: flex-start; background: #fff; border-bottom-left-radius: 6px; box-shadow: 0 4px 14px rgba(15, 40, 70, .08); transform-origin: left bottom; }
.ttl-bub--me { align-self: flex-end; color: #fff; border-bottom-right-radius: 6px; background: linear-gradient(135deg, #1A9AD9, var(--ttl-blue)); box-shadow: 0 6px 16px rgba(20, 139, 198, .28); transform-origin: right bottom; }
.ttl-bub--card { width: 100%; max-width: 100%; padding: 0; background: transparent; box-shadow: none; }
.ttl-bub--media { padding: 9px 10px; }

/* keadaan awal sebelum muncul (hanya ditambah JS); .is-in memicu transisi masuk */
.ttl-bub.is-enter { opacity: 0; transform: translateY(16px) scale(.96); transition: opacity .45s ease, transform .6s var(--ttl-ease); }
.ttl-bub.is-enter.is-in { opacity: 1; transform: none; }

.ttl-bub--typing { padding: 13px 16px; }
.ttl-typing { display: inline-flex; align-items: center; gap: 5px; }
.ttl-typing i { width: 6px; height: 6px; border-radius: 50%; background: #94A3B8; animation: ttl-dot 1.1s infinite; }
.ttl-typing i:nth-child(2) { animation-delay: .15s; } .ttl-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ttl-dot { 40% { transform: translateY(-5px); opacity: 1; } 0%, 80%, 100% { opacity: .45; } }

/* berkas yang dikirim (nota, video) */
.ttl-file { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.ttl-file__ic { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 15px; background: rgba(255, 255, 255, .22); }
.ttl-file__meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ttl-file__meta b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttl-file__meta small { font-size: 11px; line-height: 1.35; opacity: .9; }
.ttl-file__bar { height: 4px; margin-top: 3px; border-radius: 4px; background: rgba(255, 255, 255, .28); overflow: hidden; }
.ttl-file__bar i { display: block; width: 100%; height: 100%; border-radius: 4px; background: #fff; transform-origin: left; }
.ttl-file__ok { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; background: #fff; color: var(--ttl-green); }
.ttl-bub.is-enter .ttl-file__bar i { transform: scaleX(0); }
.ttl-bub.is-enter.is-in .ttl-file__bar i { transform: scaleX(1); transition: transform 1s var(--ttl-ease) .25s; }
.ttl-bub.is-enter .ttl-file__ok { opacity: 0; transform: scale(.4); }
.ttl-bub.is-enter.is-in .ttl-file__ok { opacity: 1; transform: none; transition: opacity .3s ease 1.15s, transform .4s var(--ttl-ease) 1.15s; }

/* kartu tabel / rincian biaya */
.ttl-card { padding: 12px 14px; border-radius: 16px; background: #fff; border: 1px solid #E6EEF6; box-shadow: 0 6px 18px rgba(15, 40, 70, .1); }
.ttl-card__k { margin-bottom: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ttl-blue-700); }
.ttl-card__row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px dashed #E1EAF2; font-size: 12.5px; }
.ttl-card__row span { color: var(--ttl-muted); }
.ttl-card__row b { font-weight: 600; color: var(--ttl-ink); text-align: right; }
.ttl-card__total { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 6px; padding: 9px 12px; border-radius: 11px; font-size: 12.5px; font-weight: 600; color: var(--ttl-blue-700); background: var(--ttl-sky); }
.ttl-card__total b { font-size: 15px; }

/* kartu estimasi */
.ttl-est { position: relative; overflow: hidden; padding: 15px 16px 14px; border-radius: 18px; color: #fff; background: linear-gradient(135deg, #0A3F66, var(--ttl-blue)); box-shadow: 0 12px 28px rgba(10, 63, 102, .35); }
.ttl-est::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .16) 48%, transparent 66%); transform: translateX(-120%); animation: ttl-shine 3.4s ease-in-out 1.4s infinite; }
@keyframes ttl-shine { 55%, 100% { transform: translateX(120%); } }
.ttl-est__k { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.ttl-est__v { margin: 5px 0 10px; font-size: 21px; font-weight: 800; letter-spacing: .01em; }
.ttl-est__bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.ttl-est__bar i { display: block; width: 72%; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #FFD84D, #FCBE00); transform-origin: left; }
.ttl-bub.is-enter .ttl-est__bar i { transform: scaleX(0); }
.ttl-bub.is-enter.is-in .ttl-est__bar i { transform: scaleX(1); transition: transform 1.6s var(--ttl-ease) .35s; }
.ttl-est__rows { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.ttl-est__rows li { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.ttl-est__rows li i { font-size: 12px; color: #7CF3B1; }
.ttl-est__rows li span { flex: 1; opacity: .9; }
.ttl-est__rows li b { font-weight: 600; }
.ttl-est__note { margin-top: 11px; font-size: 11px; line-height: 1.45; opacity: .82; }

/* ---------- chip mengambang (di atas kartu supaya tidak tertutup) ---------- */
.ttl-chip-float {
    position: absolute; z-index: 3; display: inline-flex; align-items: center; gap: 10px; padding: 10px 15px 10px 10px; border-radius: 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
    background: #fff; color: var(--ttl-ink); box-shadow: 0 16px 36px rgba(2, 12, 28, .38); animation: ttl-bob 5s ease-in-out infinite;
}
.ttl-chip-float i { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; color: #fff; background: var(--ttl-blue); }
.ttl-chip-float--a { top: 20px; left: 4%; } .ttl-chip-float--a i { background: var(--ttl-green); }
.ttl-chip-float--c { top: 34px; right: 3%; animation-delay: -3s; } .ttl-chip-float--c i { background: var(--ttl-blue); }
.ttl-chip-float--b { bottom: -14px; right: 3%; animation-delay: -1.5s; } .ttl-chip-float--b i { background: #F59E0B; }

/* ---------- responsif ---------- */
@media (max-width: 1100px) {
    .ttl-stage { min-height: 0; padding: 62px 0 6px; }
    .ttl-chat { height: 520px; transform: none; animation: ttl-float-flat 8s ease-in-out infinite; margin: 0 auto; }
    @keyframes ttl-float-flat { 50% { transform: translateY(-10px); } }
    .ttl-chip-float--a { left: 8%; } .ttl-chip-float--c { right: 8%; } .ttl-chip-float--b { right: 8%; }
}
@media (max-width: 560px) {
    .ttl-stage { padding: 56px 0 4px; }
    .ttl-chat { height: 500px; border-radius: 26px; }
    .ttl-chat__track { padding: 16px 14px 14px; }
    .ttl-bub { font-size: 13px; }
    .ttl-chat__label { max-width: 42%; font-size: 10.5px; padding: 5px 10px; }
    .ttl-chip-float { font-size: 12px; padding: 8px 12px 8px 8px; }
    .ttl-chip-float i { width: 26px; height: 26px; font-size: 12px; }
    .ttl-chat__dots { justify-self: start; margin-left: 6%; }
    .ttl-chip-float--a { top: 16px; left: 4%; } .ttl-chip-float--b { bottom: -12px; right: 4%; } .ttl-chip-float--c { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .ttl-chat { transform: none; }
    .ttl-stage::before { animation: none; }
}
