/**
 * Stylesheet Komponen mySPIL Chat
 * Modul penataan gaya widget chat mySPIL
 */

:root {
    --spil-green: #0aaa51;
    --spil-green-hover: #088c42;
    --chat-bg: #efeae2;
    --bubble-bot: #ffffff;
    --bubble-user: #d9fdd3;
    --bubble-me: #d9fdd3;
    --text-main: #111b21;
    --text-muted: #667781;
    --shadow: 0 1px 2px rgba(11,20,26,.13);
    --bar: #f0f2f5;
}

/* Reset dasar komponen #myspil-chat-wrapper */
#myspil-chat-wrapper {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Pastikan modal chatbot Estiva berada di atas widget mySPIL Chat */
#chatbot-modal {
    z-index: 1038 !important;
}

/* Nonaktifkan interaksi chat saat modal Bootstrap (Login/Register) aktif */
body.modal-open #myspil-chat-wrapper,
#myspil-chat-wrapper.chat-modal-disabled {
    z-index: 1020 !important;
    pointer-events: none !important;
}

/* Sembunyikan widget chat saat modal chatbot Estiva terbuka */
#myspil-chat-wrapper.chat-hidden-by-chatbot {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Sembunyikan floating button lain (Estiva & WhatsApp) saat salah satu modal chat aktif agar tidak bertubrukan */
#chatbot-gif.myspil-float-hidden,
#chatbotmenu.myspil-float-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease, visibility 0.2s ease !important;
}

/* Penyelarasan posisi tumpukan 3 floating button (Opsi 1: #chat-fab -> #chatbot-gif -> #chatbotmenu WA) */
#chatbotmenu {
    top: auto !important;
    bottom: 15px !important;
    right: 15px !important;
    margin-top: 0 !important;
}

#chatbot-gif {
    bottom: 78px !important;
    right: -20px !important;
}

/* Pastikan modal login tetap di atas chatbot jika keduanya aktif */
body.modal-open #chatbot-modal {
    z-index: 1020 !important;
}

body.modal-open #chatbot-gif,
body.modal-open #chatbotmenu {
    z-index: 790 !important;
    pointer-events: none !important;
}

#myspil-chat-wrapper * {
    box-sizing: border-box;
}

#myspil-chat-wrapper button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0;
    box-sizing: border-box;
    outline: none;
}

#myspil-chat-wrapper svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    display: block;
}

/* Scrollbar modern bentuk pill khusus widget chat */
#myspil-chat-wrapper ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

#myspil-chat-wrapper ::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}

#myspil-chat-wrapper ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.16);
    border-radius: 9999px;
}

#myspil-chat-wrapper ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.32);
}

/* Kompatibilitas scrollbar Firefox & W3C Standard */
#myspil-chat-wrapper .chat-body,
#myspil-chat-wrapper textarea,
#myspil-chat-wrapper .sp-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.16) transparent;
    -webkit-overflow-scrolling: touch;
}

/* Sembunyikan scrollbar untuk Chips dan Tray Lampiran */
#myspil-chat-wrapper .chips::-webkit-scrollbar,
#myspil-chat-wrapper .tray::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

#myspil-chat-wrapper .chips,
#myspil-chat-wrapper .tray {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;     /* Firefox */
    -webkit-overflow-scrolling: touch;
}

/* Tombol Floating Action Button (FAB) - Posisi 1 (paling atas di tumpukan kanan bawah) */
#chat-fab {
    width: 60px;
    height: 60px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease;
    user-select: none;
    position: fixed;
    bottom: 234px;
    right: 15px;
    z-index: 1030;
    display: grid;
    place-items: center;
    overflow: visible;
}

#chat-fab:hover {
    transform: scale(1.06);
}

/* Ikon SVG tombol FAB */
#chat-fab .chat-fab-icon-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    display: block;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.22));
    transition: filter 0.15s ease;
}

#chat-fab:hover .chat-fab-icon-img {
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.3));
}

/* Mode fallback teks jika gambar SVG gagal dimuat */
#chat-fab.fab-fallback-active {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background-color: var(--spil-green);
    color: white;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    font-size: 26px;
}

#chat-fab .chat-fab-fallback {
    line-height: 1;
    font-size: 26px;
}

#myspil-chat-wrapper #chat-fab .chat-badge,
#chat-fab .chat-badge,
.chat-badge {
    position: absolute !important;
    top: -2px !important;
    right: -2px !important;
    min-width: 20px !important;
    height: 20px !important;
    padding: 0 5px !important;
    background: linear-gradient(135deg, #ff4d4f 0%, #e02424 100%) !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    border-radius: 9999px !important;
    border: 1px solid rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28) !important;
    display: none;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    pointer-events: none !important;
    z-index: 10 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

#myspil-chat-wrapper #chat-fab .chat-badge.on,
#chat-fab .chat-badge.on,
.chat-badge.on {
    display: inline-flex !important;
    animation: chatBadgePop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

@keyframes chatBadgePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Kontainer Jendela Chat */
#chat-window {
    width: calc(100vw - 30px);
    max-width: 400px;
    height: 650px;
    max-height: calc(100vh - 80px);
    display: none;
    flex-direction: column;
    box-shadow: 0 12px 44px rgba(0,0,0,.18);
    border-radius: 22px;
    overflow: hidden;
    background: var(--chat-bg);
    margin-bottom: 15px;
    position: relative;
}

/* Header Chat */
.chat-header {
    background-color: var(--spil-green);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2;
    box-shadow: 0 2px 12px rgba(0,0,0,.14);
}

/* Avatar foto profil dengan teks fallback */
#myspil-chat-wrapper .chat-header .avatar,
.chat-header .avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: white;
    color: var(--spil-green);
    flex: none;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#myspil-chat-wrapper .chat-header .avatar .fallback-text,
.chat-header .avatar .fallback-text {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 17px;
    z-index: 1;
}

#myspil-chat-wrapper .chat-header .avatar img,
.chat-header .avatar img {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-header .title-area {
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}

.chat-header .title-area strong {
    display: block;
    font-weight: 600;
    font-size: 16px;
}

.chat-header .title-area small {
    font-size: 12.5px;
    opacity: 0.85;
}

.chat-header button {
    background: none;
    border: none;
    color: white;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    cursor: pointer;
}

.chat-header button:hover {
    background: rgba(255,255,255,.14);
}

.chat-header button svg {
    width: 21px;
    height: 21px;
}

/* Area Pesan Obrolan */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scroll-behavior: smooth;
    overflow-anchor: none;
}

/* Tampilan chat kosong (Welcome State) */
#myspil-chat-wrapper .chat-empty-state,
.chat-empty-state {
    margin: auto auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: clamp(16px, 4vh, 28px) clamp(16px, 5vw, 24px);
    user-select: none;
    animation: fadeInEmptyState 0.28s cubic-bezier(0.2, 0.8, 0.3, 1) both;
    width: 100%;
    box-sizing: border-box;
}

@keyframes fadeInEmptyState {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#myspil-chat-wrapper .chat-empty-state-icon,
.chat-empty-state-icon {
    width: clamp(76px, 18vw, 92px);
    height: clamp(76px, 18vw, 92px);
    min-width: 76px;
    min-height: 76px;
    border-radius: 50%;
    background-color: rgba(10, 170, 81, 0.14) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto clamp(16px, 3vh, 24px) auto;
    box-shadow: 0 4px 16px rgba(10, 170, 81, 0.08);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
}

#myspil-chat-wrapper .chat-empty-state-icon:hover {
    transform: scale(1.04);
}

#myspil-chat-wrapper .chat-empty-state-icon svg,
.chat-empty-state-icon svg {
    width: clamp(42px, 10vw, 52px) !important;
    height: clamp(42px, 10vw, 52px) !important;
    fill: var(--spil-green, #0aaa51) !important;
    color: var(--spil-green, #0aaa51) !important;
    display: block !important;
}

#myspil-chat-wrapper .chat-empty-state-title,
.chat-empty-state-title {
    font-size: clamp(18px, 4.5vw, 22px) !important;
    font-weight: 700 !important;
    color: var(--text-main, #111b21) !important;
    margin: 0 0 clamp(8px, 1.8vh, 12px) 0 !important;
    line-height: 1.3 !important;
    letter-spacing: -0.02em !important;
}

#myspil-chat-wrapper .chat-empty-state-subtitle,
.chat-empty-state-subtitle {
    font-size: clamp(13.5px, 3.2vw, 15px) !important;
    color: var(--text-muted, #667781) !important;
    line-height: 1.55 !important;
    max-width: clamp(260px, 80vw, 340px) !important;
    margin: 0 auto !important;
    text-wrap: balance;
}

/* Pembatas tanggal obrolan (Pill Divider) */
#myspil-chat-wrapper .chat-date-chip,
.chat-date-chip {
    align-self: center;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #ffffff !important;
    color: #54656f !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    min-height: 30px !important;
    padding: 0 16px !important;
    box-sizing: border-box !important;
    border-radius: 999px !important;
    box-shadow: 0 1px 2px rgba(11, 20, 26, 0.12), 0 1px 0 rgba(0, 0, 0, 0.04) !important;
    border: 1px solid rgba(11, 20, 26, 0.08) !important;
    margin: 20px auto 14px !important;
    user-select: none;
    pointer-events: none;
    letter-spacing: 0.25px;
    max-width: 85%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2;
}

#myspil-chat-wrapper .chat-date-chip:first-child,
.chat-date-chip:first-child {
    margin-top: 14px !important;
}

.message-row {
    display: flex;
    width: 100%;
    position: relative;
    animation: pop .24s cubic-bezier(.2,.8,.3,1) both;
    margin-top: 2px;
}

.message-row.first {
    margin-top: 6px;
}

.message-row.me {
    justify-content: flex-end;
    transform-origin: 100% 100%;
}

.message-row.bot {
    justify-content: flex-start;
    transform-origin: 0 100%;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.96);
    }
}

@keyframes fl {
    0%, 60% {
        filter: brightness(.88);
    }
    100% {
        filter: none;
    }
}

.message-row.flash .bubble {
    animation: fl 1.2s;
}

.bubble {
    position: relative;
    max-width: 84%;
    padding: 8px 10px 7px 12px;
    border-radius: 16px;
    font-size: 15px;
    color: var(--text-main);
    background: var(--bubble-bot);
    box-shadow: var(--shadow);
    word-wrap: break-word;
    min-width: 78px;
    transition: filter .3s;
}

.me .bubble {
    background: var(--bubble-user);
    border-top-right-radius: 4px;
    min-width: 86px;
}

.bot .bubble {
    border-top-left-radius: 4px;
}

/* Balon kutipan / reply pesan */
#myspil-chat-wrapper .bubble .q,
.bubble .q,
#myspil-chat-wrapper .q,
.q {
    display: flex !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
    text-align: left !important;
    background: rgba(0, 0, 0, 0.05) !important;
    border: none !important;
    border-left: 4px solid var(--spil-green) !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    margin-bottom: 6px !important;
    font-size: 13px !important;
    font-family: inherit !important;
    transition: filter .15s !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    outline: none !important;
    overflow: hidden !important;
}

#myspil-chat-wrapper .q:hover,
.q:hover {
    filter: brightness(.95) !important;
}

#myspil-chat-wrapper .q:active,
.q:active {
    filter: brightness(.90) !important;
}

#myspil-chat-wrapper .me .q,
.me .q {
    background: rgba(0, 0, 0, 0.07) !important;
    border-left: 4px solid var(--spil-green) !important;
}

#myspil-chat-wrapper .bot .q,
.bot .q {
    background: rgba(0, 0, 0, 0.05) !important;
    border-left: 4px solid var(--spil-green) !important;
}

#myspil-chat-wrapper .q .q-content,
.q .q-content {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    overflow: hidden !important;
}

#myspil-chat-wrapper .q b,
.q b {
    display: block !important;
    color: var(--spil-green) !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    margin-bottom: 2px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

#myspil-chat-wrapper .q span,
.q span {
    color: var(--text-muted) !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
    margin: 0 !important;
}

/* Kotak pratinjau media di dalam kutipan (Thumbnail foto / badge dokumen) */
#myspil-chat-wrapper .q:not(.has-media) .q-media,
.q:not(.has-media) .q-media,
#myspil-chat-wrapper .q-media:empty,
.q-media:empty,
#myspil-chat-wrapper .q-media[style*="display: none"],
.q-media[style*="display: none"],
#myspil-chat-wrapper .q-media.is-hidden,
.q-media.is-hidden,
#rpm:empty,
#myspil-chat-wrapper #rpm[style*="display: none"],
#rpm[style*="display: none"],
#myspil-chat-wrapper #rpm.is-hidden,
#rpm.is-hidden {
    display: none !important;
}

#myspil-chat-wrapper .q.has-media .q-media,
.q.has-media .q-media,
#myspil-chat-wrapper .q .q-media:not(:empty),
.q .q-media:not(:empty) {
    flex: 0 0 44px !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.06) !important;
    align-self: center !important;
}

#myspil-chat-wrapper .q .q-media img,
.q .q-media img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

#myspil-chat-wrapper .q .q-media .q-doc-badge,
.q .q-media .q-doc-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 4px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    line-height: 1 !important;
}

#myspil-chat-wrapper .bubble-meta,
.bubble-meta {
    position: absolute !important;
    right: 8px !important;
    bottom: 4px !important;
    font-size: 11px !important;
    color: var(--text-muted) !important;
    display: flex !important;
    gap: 3px !important;
    align-items: center !important;
    line-height: 1 !important;
}

#myspil-chat-wrapper .bubble-meta .tk {
    display: inline-flex !important;
    align-items: center !important;
}

#myspil-chat-wrapper .bubble-meta .tk.tk--pending,
.starred-bubble .bubble-meta .tk.tk--pending {
    color: #8696A0 !important;
}

#myspil-chat-wrapper .bubble-meta .tk.tk--sent,
.starred-bubble .bubble-meta .tk.tk--sent {
    color: #53bdeb !important;
}

#myspil-chat-wrapper .bubble-meta .tk.tk--failed,
.starred-bubble .bubble-meta .tk.tk--failed {
    color: #e5484d !important;
}

#myspil-chat-wrapper .bubble-meta .star-badge,
.bubble-meta .star-badge {
    display: inline-flex !important;
    align-items: center !important;
    margin-right: 3px !important;
}

#myspil-chat-wrapper .bubble-meta .star-badge:empty,
.bubble-meta .star-badge:empty {
    display: none !important;
    margin-right: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

#myspil-chat-wrapper .bubble-meta .star-badge svg,
.bubble-meta .star-badge svg {
    width: 12px !important;
    height: 12px !important;
    fill: #e5a100 !important;
}

#myspil-chat-wrapper .bubble-meta svg,
#myspil-chat-wrapper .bubble-meta .tk svg,
.bubble-meta svg {
    width: 15px !important;
    height: 15px !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

#myspil-chat-wrapper .bubble-meta .tk svg {
    fill: currentColor !important;
}

.bubble .txt {
    white-space: pre-wrap;
    padding-right: 60px;
}

.me .bubble .txt {
    padding-right: 74px;
}

.bubble .txt.alone {
    padding-right: 0;
}

/* Tampilan media gambar dan video di balon pesan */
.imgs {
    display: grid;
    gap: 3px;
    margin-bottom: 4px;
    grid-template-columns: 1fr;
}

.imgs.n2, .imgs.n3, .imgs.n4 {
    grid-template-columns: 1fr 1fr;
}

.imgs button[data-img] {
    border-radius: 12px;
    overflow: hidden;
    display: block;
    aspect-ratio: 4/3;
}

.imgs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.imgs .vd {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #111b21;
    width: fit-content;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.imgs.n1 .vd {
    width: fit-content;
    max-width: 100%;
    max-height: 320px;
}

/* Penyelarasan lebar bubble video tunggal agar ramping mengikuti video tanpa ruang kosong kiri-kanan */
#myspil-chat-wrapper .bubble.has-video {
    min-width: 165px;
}

#myspil-chat-wrapper .bubble.has-video .imgs.n1 .vd {
    width: 100%;
}

#myspil-chat-wrapper .bubble.has-video .txt:not(.alone) {
    width: 0;
    min-width: 100%;
    padding-right: 0;
    padding-bottom: 18px;
    overflow-wrap: break-word;
}

.imgs.n2 .vd, .imgs.n3 .vd, .imgs.n4 .vd {
    aspect-ratio: 4 / 3;
    max-height: 180px;
    width: 100%;
}

.imgs video {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 320px;
    display: block;
    object-fit: contain;
    border-radius: 12px;
}

.imgs.n2 video, .imgs.n3 video, .imgs.n4 video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Sembunyikan kontrol native browser hanya pada mode lightbox agar menampilkan play badge WhatsApp */
.imgs .vd.vd-lightbox-item video::-webkit-media-controls,
.imgs .vd.vd-lightbox-item video::-webkit-media-controls-enclosure {
    display: none !important;
}

/* Tampilan pemutar video inline di dalam balon chat */
.imgs .vd:not(.vd-lightbox-item) {
    min-width: 220px;
    width: 100%;
}

.imgs .vd:not(.vd-lightbox-item) video {
    width: 100%;
}

/* Tombol putar video di balon chat (gaya WhatsApp) */
.vd.vd-lightbox-item {
    cursor: pointer;
}

.imgs .vd-play-badge,
.vd-play-badge {
    position: absolute;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    background: rgba(11, 20, 26, 0.68) !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45) !important;
    cursor: pointer !important;
    z-index: 5 !important;
    padding: 0 !important;
    aspect-ratio: auto !important;
    overflow: visible !important;
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1), background 0.2s, border-color 0.2s !important;
}

.imgs .vd.vd-lightbox-item:hover .vd-play-badge,
.vd.vd-lightbox-item:hover .vd-play-badge {
    transform: translate(-50%, -50%) scale(1.12) !important;
    background: rgba(0, 166, 91, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.7) !important;
}

.vd-play-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.vd-play-icon svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
    margin-left: 3px;
}

@media (max-width: 360px) {
    .imgs.n1 .vd {
        max-height: 210px;
        min-height: 130px;
    }
}

.file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,.05);
    border-radius: 12px;
    padding: 9px 10px;
    margin-bottom: 4px;
    color: inherit;
    text-decoration: none;
}

.file .ic {
    width: 38px;
    height: 44px;
    border-radius: 6px;
    background: #2b6cd6;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    flex: none;
}

.file div {
    min-width: 0;
}

.file b {
    display: block;
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 190px;
}

.file small {
    color: var(--text-muted);
    font-size: 12px;
}

/* Menu opsi konteks pesan (Reply, Salin, Berbintang, Bagikan) */
#myspil-chat-wrapper .mm {
    position: absolute !important;
    top: 2px !important;
    right: 2px !important;
    width: 26px !important;
    height: 22px !important;
    border-radius: 50% !important;
    display: grid !important;
    place-items: center !important;
    color: var(--text-muted) !important;
    opacity: 0 !important;
    background: linear-gradient(to left, var(--bubble-bot) 55%, transparent) !important;
    border: 0 !important;
    padding: 0 !important;
    cursor: pointer !important;
    outline: none !important;
    box-shadow: none !important;
    transition: opacity .15s !important;
    z-index: 6 !important;
    pointer-events: auto !important;
}

#myspil-chat-wrapper .me .mm,
#myspil-chat-wrapper .starred-bubble.bubble-me .mm {
    background: linear-gradient(to left, var(--bubble-user) 55%, transparent) !important;
}

#myspil-chat-wrapper .bot .mm,
#myspil-chat-wrapper .starred-bubble.bubble-bot .mm {
    background: linear-gradient(to left, var(--bubble-bot) 55%, transparent) !important;
}

#myspil-chat-wrapper .message-row:hover .mm,
#myspil-chat-wrapper .message-row.menu-open .mm,
#myspil-chat-wrapper .starred-card:hover .mm,
#myspil-chat-wrapper .starred-card.menu-open .mm,
#myspil-chat-wrapper .mm.active,
#myspil-chat-wrapper .mm:focus-visible {
    opacity: 1 !important;
}

#myspil-chat-wrapper .mm:hover,
#myspil-chat-wrapper .mm.active {
    color: var(--text-main) !important;
}

/* Badge chevron frosted glass pada balon media */
#myspil-chat-wrapper .bubble.has-media .mm,
#myspil-chat-wrapper .starred-bubble.has-media .mm {
    background: rgba(11, 20, 26, 0.55) !important;
    color: #ffffff !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 50% !important;
    width: 26px !important;
    height: 26px !important;
    top: 6px !important;
    right: 6px !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35) !important;
}

#myspil-chat-wrapper .bubble.has-media .mm:hover,
#myspil-chat-wrapper .bubble.has-media .mm.active,
#myspil-chat-wrapper .starred-bubble.has-media .mm:hover,
#myspil-chat-wrapper .starred-bubble.has-media .mm.active {
    background: rgba(11, 20, 26, 0.8) !important;
}

#myspil-chat-wrapper .bubble.has-media .mm svg,
#myspil-chat-wrapper .starred-bubble.has-media .mm svg {
    fill: #ffffff !important;
}

@media (hover: none) {
    #myspil-chat-wrapper .mm {
        opacity: 0.65 !important;
    }
}

#myspil-chat-wrapper .mm svg {
    width: 20px !important;
    height: 20px !important;
    fill: currentColor !important;
    display: block !important;
}

#myspil-chat-wrapper .menu,
#myspil-chat-wrapper #msg-menu {
    position: absolute !important;
    z-index: 8 !important;
    background: white !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,.3) !important;
    padding: 6px 0 !important;
    display: none;
    min-width: 150px !important;
    border: none !important;
    outline: none !important;
}

#myspil-chat-wrapper .menu.on,
#myspil-chat-wrapper #msg-menu.on {
    display: block !important;
    animation: pu .16s ease-out !important;
}

@keyframes pu {
    from {
        opacity: 0;
        transform: translateY(6px) scale(.96);
    }
}

#myspil-chat-wrapper .menu button,
#myspil-chat-wrapper #msg-menu button {
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
    width: 100% !important;
    padding: 9px 16px !important;
    font-size: 14.5px !important;
    font-family: inherit !important;
    color: var(--text-main) !important;
    background: transparent !important;
    border: 0 !important;
    outline: none !important;
    cursor: pointer !important;
    text-align: left !important;
    border-radius: 0 !important;
    line-height: 1.4 !important;
    font-weight: 400 !important;
    box-shadow: none !important;
    transition: background .15s !important;
}

#myspil-chat-wrapper .menu button:hover,
#myspil-chat-wrapper #msg-menu button:hover {
    background: rgba(128,128,128,.16) !important;
}

#myspil-chat-wrapper .menu svg,
#myspil-chat-wrapper #msg-menu svg {
    width: 20px !important;
    height: 20px !important;
    color: var(--text-muted) !important;
    fill: currentColor !important;
    flex: none !important;
    display: block !important;
    margin: 0 !important;
}

/* Saran tombol cepat (Quick Chips) */
#myspil-chat-wrapper .chips,
.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 10px;
    flex: none;
    background: var(--chat-bg);
}

#myspil-chat-wrapper .chips button,
#myspil-chat-wrapper #quick-chips button,
.chips button {
    white-space: nowrap !important;
    border: 1px solid var(--spil-green) !important;
    color: var(--spil-green) !important;
    background: #ffffff !important;
    border-radius: 999px !important;
    padding: 7px 14px !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    box-shadow: var(--shadow) !important;
    transition: background .18s, color .18s, transform .18s !important;
    cursor: pointer !important;
    display: inline-block !important;
    line-height: 1.4 !important;
    outline: none !important;
    height: auto !important;
    text-decoration: none !important;
}

#myspil-chat-wrapper .chips button:active,
#myspil-chat-wrapper #quick-chips button:active,
.chips button:active {
    transform: scale(.96) !important;
}

#myspil-chat-wrapper .chips button:hover,
#myspil-chat-wrapper #quick-chips button:hover,
.chips button:hover {
    background: var(--spil-green) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
}

/* Tombol melayang loncat ke pesan terbawah */
#myspil-chat-wrapper .btn-scroll-bottom,
.btn-scroll-bottom {
    position: absolute;
    right: 14px;
    bottom: 70px;
    width: 38px;
    height: 38px;
    border-radius: 50% !important;
    background: #ffffff !important;
    color: var(--text-muted, #54656f) !important;
    box-shadow: 0 3px 10px rgba(11, 20, 26, 0.22) !important;
    border: 1px solid rgba(11, 20, 26, 0.08) !important;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    z-index: 12 !important;
    transition: bottom 0.2s cubic-bezier(0.25, 1, 0.5, 1), transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease !important;
    user-select: none;
    outline: none !important;
}

#myspil-chat-wrapper .btn-scroll-bottom:hover,
.btn-scroll-bottom:hover {
    background: #ffffff !important;
    color: var(--spil-green, #0aaa51) !important;
    transform: scale(1.08) !important;
    box-shadow: 0 5px 14px rgba(11, 20, 26, 0.28) !important;
}

#myspil-chat-wrapper .btn-scroll-bottom:active,
.btn-scroll-bottom:active {
    transform: scale(0.95) !important;
}

#myspil-chat-wrapper .btn-scroll-bottom svg,
.btn-scroll-bottom svg {
    width: 22px !important;
    height: 22px !important;
    fill: currentColor !important;
    margin: 0 auto !important;
    display: block !important;
}

#myspil-chat-wrapper .btn-scroll-bottom .scroll-bottom-badge,
.btn-scroll-bottom .scroll-bottom-badge {
    position: absolute !important;
    top: -4px !important;
    right: -4px !important;
    min-width: 20px !important;
    height: 20px !important;
    padding: 0 5px !important;
    background: linear-gradient(135deg, #10b95b 0%, #0aaa51 100%) !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    border-radius: 9999px !important;
    border: 1.5px solid #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28) !important;
    display: none;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    pointer-events: none !important;
    z-index: 10 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

#myspil-chat-wrapper .btn-scroll-bottom .scroll-bottom-badge.on,
.btn-scroll-bottom .scroll-bottom-badge.on {
    display: inline-flex !important;
    animation: chatBadgePop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/* Area Dock (Panel Reply & Tray Lampiran) */
.dock {
    flex: none;
    background: var(--chat-bg);
    position: relative;
}

.rp {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 0;
}

.rp.on {
    display: flex;
}

#myspil-chat-wrapper .rp .q,
.rp .q {
    flex: 1 !important;
    margin: 0 !important;
    background: white !important;
    cursor: default !important;
    min-width: 0 !important;
}

#myspil-chat-wrapper .rp .q:not(.has-media) .q-media,
.rp .q:not(.has-media) .q-media,
#myspil-chat-wrapper #rpm:empty,
#rpm:empty,
#myspil-chat-wrapper #rpm[style*="display: none"],
#rpm[style*="display: none"],
#myspil-chat-wrapper #rpm.is-hidden,
#rpm.is-hidden {
    display: none !important;
}

#myspil-chat-wrapper .rp .q.has-media .q-media,
.rp .q.has-media .q-media,
#myspil-chat-wrapper #rpm:not(:empty),
#rpm:not(:empty) {
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 6px !important;
    display: flex !important;
}

#myspil-chat-wrapper .rp .q .q-media .q-doc-badge,
.rp .q .q-media .q-doc-badge {
    width: 34px !important;
    height: 34px !important;
    font-size: 10px !important;
}

.rp .q span {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.rp > button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--text-muted);
}

.tray {
    display: none;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 10px 0;
}

.tray.on {
    display: flex;
}

.pi {
    position: relative;
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
}

.pi img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#myspil-chat-wrapper .pi .pi-doc-badge,
.pi .pi-doc-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 8px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    line-height: 1 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    user-select: none !important;
}

.pi .x {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    color: #fff;
    display: grid;
    place-items: center;
    border: none;
    cursor: pointer;
    z-index: 2;
    padding: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}

.pi .x:hover {
    background: rgba(0,0,0,.85);
    transform: scale(1.1);
}

.pi .x svg {
    width: 14px;
    height: 14px;
}

/* Bagian input pesan dan tombol kirim */
.bar {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 6px 10px 12px;
}

.bar > button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    flex: none;
    font-size: 22px;
    line-height: 1;
    border: 0 !important;
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background .15s, transform .15s;
}

.bar > button:active {
    transform: scale(.9) !important;
}

.bar > button:hover {
    background: rgba(128,128,128,.15) !important;
}

#myspil-chat-wrapper textarea {
    flex: 1;
    resize: none;
    border: 0;
    border-radius: 22px;
    background: white;
    color: var(--text-main);
    padding: 11px 18px;
    font: inherit;
    max-height: 120px;
    height: 44px;
    line-height: 1.35;
    box-shadow: 0 1px 3px rgba(0,0,0,.14);
    transition: box-shadow .2s;
    outline: none;
    overflow-y: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Khusus textarea: track diberi jarak vertikal agar thumb tidak menabrak sudut kurva 22px */
#myspil-chat-wrapper textarea::-webkit-scrollbar-track {
    margin: 8px 0;
}

#myspil-chat-wrapper textarea:focus {
    box-shadow: 0 0 0 2px var(--spil-green), 0 2px 8px rgba(10,170,81,.2);
}

#myspil-chat-wrapper textarea::placeholder {
    color: var(--text-muted);
}

#myspil-chat-wrapper textarea:disabled {
    background: #f7f7f7 !important;
    cursor: not-allowed !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
}

/* Tautan pemicu login di dalam balon pesan */
.chat-login-trigger {
    color: var(--spil-green);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.chat-login-trigger:hover {
    color: var(--spil-green-hover);
    text-decoration: underline;
}

/* Tampilan pengunci mode guest */
#myspil-chat-wrapper.chat-guest-mode .chips {
    display: none !important;
}

#myspil-chat-wrapper.chat-guest-mode #btn-attach,
#myspil-chat-wrapper.chat-guest-mode #btn-emoji,
#myspil-chat-wrapper.chat-guest-mode #btn-send,
#myspil-chat-wrapper.chat-loading-mode #btn-attach,
#myspil-chat-wrapper.chat-loading-mode #btn-emoji,
#myspil-chat-wrapper.chat-loading-mode #btn-send {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

#myspil-chat-wrapper.chat-loading-mode #chat-input {
    cursor: not-allowed !important;
    background-color: #f7f9fa !important;
}

/* Pengunci aksi chat jika user tidak memenuhi syarat */
#myspil-chat-wrapper.chat-unauthorized-mode .chips {
    display: none !important;
}

#myspil-chat-wrapper.chat-unauthorized-mode #btn-attach,
#myspil-chat-wrapper.chat-unauthorized-mode #btn-emoji,
#myspil-chat-wrapper.chat-unauthorized-mode #btn-send {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

#myspil-chat-wrapper.chat-unauthorized-mode #chat-input:disabled {
    background-color: #f7f9fa !important;
    cursor: not-allowed !important;
}

#myspil-chat-wrapper #btn-send,
#myspil-chat-wrapper #send,
#btn-send, #send {
    background: var(--spil-green) !important;
    color: white !important;
    box-shadow: 0 2px 6px rgba(10,170,81,.35) !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    display: grid !important;
    place-items: center !important;
    cursor: pointer !important;
}

#myspil-chat-wrapper #btn-send:disabled,
#myspil-chat-wrapper #send:disabled,
#btn-send:disabled, #send:disabled {
    background: white !important;
    color: var(--text-muted) !important;
    cursor: default !important;
    box-shadow: none !important;
    border: 0 !important;
    padding: 0 !important;
}

/* Pop-up lampiran & pilihan emoji */
.pop {
    position: absolute;
    bottom: 62px;
    left: 10px;
    background: white;
    border-radius: 14px;
    box-shadow: 0 4px 22px rgba(0,0,0,.28);
    padding: 8px;
    display: none;
    z-index: 5;
}

.pop.on {
    display: block;
    animation: pu .18s ease-out;
}

.att {
    padding: 6px;
    min-width: 170px;
}

#myspil-chat-wrapper .att button,
.att button {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    padding: 7px 12px 7px 10px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    justify-content: flex-start !important;
    background: transparent !important;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    cursor: pointer !important;
    color: var(--text-main) !important;
}

#myspil-chat-wrapper .att button:hover,
.att button:hover {
    background: rgba(128,128,128,.14) !important;
}

.att .c svg {
    width: 20px;
    height: 20px;
}

.emo {
    width: min(320px, calc(100% - 20px));
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.emo.on {
    display: grid;
}

#myspil-chat-wrapper .emo button,
.emo button {
    font-size: 23px !important;
    height: 38px !important;
    border-radius: 8px !important;
    display: grid !important;
    place-items: center !important;
    background: transparent !important;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    cursor: pointer !important;
}

#myspil-chat-wrapper .emo button:hover,
.emo button:hover {
    background: rgba(128,128,128,.18) !important;
}

/* Overlay UI: Toast bergaya glassmorphism */
.toast-ui { 
    position: absolute;
    left: 50%;
    top: 70px;
    transform: translateX(-50%); 
    background: rgba(20, 25, 30, 0.7); /* Dark Semi-transparent */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* Glass effect */
    border: 1px solid rgba(255, 255, 255, 0.15); /* Glass edge */
    color: #fff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13.5px;
    font-weight: 500;
    z-index: 25;
    display: none;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.toast-ui.on {
    display: block;
    animation: pu .2s ease-out;
}

.lb {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    place-items: center;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    padding: 60px 20px 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.lb.on {
    display: flex;
}

.lb img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    transition: transform 0.2s cubic-bezier(0.2, 0, 0.2, 1);
    cursor: zoom-in;
    user-select: none;
    touch-action: none;
}

.lb img.zoomed {
    cursor: grab;
    transform: scale(2);
}

.lb img.zoomed.panning {
    cursor: grabbing;
    transition: none;
}

.lb video {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    background: #000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
    outline: none;
}

.lb button#btn-close-lb,
.lb button {
    position: absolute;
    top: 16px;
    right: 18px;
    color: #ffffff;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, border-color 0.2s;
    z-index: 1000000;
}

.lb button#btn-close-lb:hover,
.lb button:hover {
    background: rgba(239, 68, 68, 0.85);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
}

.sheet {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: flex-end;
    z-index: 15;
}

.sheet.on {
    display: flex;
}

.card-sheet {
    background: white;
    width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 16px;
}

.card-sheet p {
    margin: 8px 0 12px;
    padding: 10px 12px;
    color: var(--text-muted);
    background: #f5f7f8;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    max-height: 110px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 13.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.16) transparent;
    -webkit-overflow-scrolling: touch;
}

.so {
    display: flex;
    gap: 8px;
}

#myspil-chat-wrapper .so a,
#myspil-chat-wrapper .so button,
.so a, .so button {
    flex: 1 !important;
    text-align: center !important;
    padding: 11px 6px !important;
    border-radius: 10px !important;
    background: var(--bar) !important;
    color: var(--text-main) !important;
    text-decoration: none !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    border: none !important;
    outline: none !important;
    cursor: pointer !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
}

#myspil-chat-wrapper .so a:hover,
#myspil-chat-wrapper .so button:hover,
.so a:hover, .so button:hover {
    background: rgba(128,128,128,.2) !important;
}

#myspil-chat-wrapper .cx,
.cx {
    width: 100% !important;
    margin-top: 10px !important;
    padding: 10px !important;
    color: var(--spil-green) !important;
    font-weight: 600 !important;
    border: none !important;
    background: transparent !important;
    cursor: pointer !important;
    font-size: 14px !important;
    outline: none !important;
    box-shadow: none !important;
}

#history-panel {
    position: absolute;
    inset: 0;
    background: var(--chat-bg);
    z-index: 5;
    display: none;
    flex-direction: column;
}

#history-panel.on {
    display: flex;
}

/* Kotak pencarian riwayat chat */
.history-search-wrap {
    padding: 10px 14px 6px;
    background: var(--chat-bg);
    flex-shrink: 0;
}

#myspil-chat-wrapper .history-search-box,
.history-search-box {
    display: flex;
    align-items: center;
    height: 38px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 9999px !important;
    padding: 0 14px;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

#myspil-chat-wrapper .history-search-box:focus-within,
.history-search-box:focus-within {
    border-color: var(--spil-green, #0aaa51);
    box-shadow: 0 2px 10px rgba(10, 170, 81, 0.15);
}

#myspil-chat-wrapper .history-search-icon,
.history-search-icon {
    display: block;
    width: 17px !important;
    height: 17px !important;
    fill: var(--text-muted, #667781) !important;
    flex-shrink: 0;
    margin: 0;
}

/* Reset margin & padding global input[type="text"] agar teks sejajar tengah dengan ikon */
#myspil-chat-wrapper #history-search-input,
#history-search-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 36px !important;
    line-height: normal !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text-main, #111b21);
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
}

#myspil-chat-wrapper #history-search-input::placeholder,
#history-search-input::placeholder {
    color: #94a3b8;
    opacity: 1;
}

#myspil-chat-wrapper .history-search-clear,
.history-search-clear {
    background: transparent;
    border: none;
    width: 22px;
    height: 22px;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50% !important;
    transition: background 0.15s ease;
}

#myspil-chat-wrapper .history-search-clear:hover,
.history-search-clear:hover {
    background: rgba(0, 0, 0, 0.06);
}

#myspil-chat-wrapper .history-search-clear svg,
.history-search-clear svg {
    display: block;
    width: 15px !important;
    height: 15px !important;
    fill: var(--text-muted, #667781) !important;
}

/* Kontainer daftar riwayat chat */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}

/* Kartu riwayat sesi obrolan */
.history-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
    user-select: none;
    box-sizing: border-box;
    width: 100%;
}

.history-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(10, 170, 81, 0.10);
    border-color: rgba(10, 170, 81, 0.35);
}

.history-card:active {
    transform: scale(0.99);
}

.history-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.history-card-case-id {
    font-size: 13px;
    font-weight: 700;
    color: var(--spil-green, #0aaa51);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.history-card-date {
    font-size: 11.5px;
    color: #8c9ba5;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}

.history-card-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main, #111b21);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.history-card-preview {
    font-size: 12.5px;
    color: var(--text-muted, #667781);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    margin-top: 1px;
}

/* Footer aksi mikro kartu riwayat ('Lihat Detail Chat') */
.history-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 6px;
    padding-top: 7px;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
    pointer-events: none;
}

.history-card-action-text {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--spil-green, #0aaa51);
    line-height: 1;
    letter-spacing: -0.01em;
    transition: color 0.15s ease;
}

.history-card-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--spil-green, #0aaa51);
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1), color 0.15s ease;
}

.history-card-action-icon svg {
    width: 13px !important;
    height: 13px !important;
    fill: currentColor !important;
    display: block !important;
}

.history-card:hover .history-card-action-text {
    color: var(--spil-green-hover, #088c42);
}

.history-card:hover .history-card-action-icon {
    transform: translateX(3px);
    color: var(--spil-green-hover, #088c42);
}

/* Efek shimmer loading riwayat chat */
.history-skeleton-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    box-sizing: border-box;
    width: 100%;
}

.history-skeleton-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.history-skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: #e2e8f0;
    animation: historySkeletonPulse 1.4s ease-in-out infinite;
}

.history-skeleton-line.code {
    width: 38%;
}

.history-skeleton-line.date {
    width: 24%;
}

.history-skeleton-line.title {
    width: 65%;
}

.history-skeleton-line.preview {
    width: 90%;
}

.history-skeleton-line.footer {
    width: 32%;
    align-self: flex-end;
    margin-top: 4px;
}

@keyframes historySkeletonPulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Efek shimmer loading pesan chat */
#myspil-chat-wrapper .chat-skeleton-wrap,
.chat-skeleton-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 4px;
    width: 100%;
    box-sizing: border-box;
}

#myspil-chat-wrapper .chat-skeleton-row,
.chat-skeleton-row {
    display: flex;
    width: 100%;
}

#myspil-chat-wrapper .chat-skeleton-row.bot,
.chat-skeleton-row.bot {
    justify-content: flex-start;
}

#myspil-chat-wrapper .chat-skeleton-row.me,
.chat-skeleton-row.me {
    justify-content: flex-end;
}

#myspil-chat-wrapper .chat-skeleton-bubble,
.chat-skeleton-bubble {
    border-radius: 14px;
    background: #e2e8f0;
    animation: historySkeletonPulse 1.4s ease-in-out infinite;
}

#myspil-chat-wrapper .chat-skeleton-row.bot .chat-skeleton-bubble,
#myspil-chat-wrapper .chat-skeleton-bubble.bot,
.chat-skeleton-row.bot .chat-skeleton-bubble,
.chat-skeleton-bubble.bot {
    width: 68%;
    height: 48px;
    border-bottom-left-radius: 4px;
}

#myspil-chat-wrapper .chat-skeleton-row.me .chat-skeleton-bubble,
#myspil-chat-wrapper .chat-skeleton-bubble.me,
.chat-skeleton-row.me .chat-skeleton-bubble,
.chat-skeleton-bubble.me {
    width: 55%;
    height: 40px;
    background: rgba(10, 170, 81, 0.18);
    border-bottom-right-radius: 4px;
}

#myspil-chat-wrapper .chat-skeleton-row.bot.short .chat-skeleton-bubble,
#myspil-chat-wrapper .chat-skeleton-bubble.bot.short,
.chat-skeleton-row.bot.short .chat-skeleton-bubble,
.chat-skeleton-bubble.bot.short {
    width: 45%;
    height: 36px;
}

@media (prefers-reduced-motion: reduce) {
    #myspil-chat-wrapper .chat-skeleton-bubble,
    .chat-skeleton-bubble {
        animation: none;
    }
}

/* Banner mode baca riwayat sesi tertutup */
.chat-history-dock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
    animation: fadeInEmptyState 0.2s ease both;
    flex-shrink: 0;
}

.chat-history-dock-info {
    flex: 1;
    min-width: 0;
}

.chat-history-dock-text {
    font-size: 13px;
    color: var(--text-muted, #667781);
    font-weight: 500;
    display: block;
    line-height: 1.35;
}

#myspil-chat-wrapper .btn-return-active-chat,
.btn-return-active-chat {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    background: var(--spil-green, #0aaa51) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 9999px !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: 0 2px 8px rgba(10, 170, 81, 0.28) !important;
    transition: background-color 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease !important;
    white-space: nowrap !important;
    user-select: none !important;
    flex-shrink: 0;
}

#myspil-chat-wrapper .btn-return-active-chat:hover,
.btn-return-active-chat:hover {
    background: var(--spil-green-hover, #088c42) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(10, 170, 81, 0.38) !important;
}

#myspil-chat-wrapper .btn-return-active-chat:active,
.btn-return-active-chat:active {
    transform: scale(0.97) !important;
}

.btn-return-active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 6px #ffffff;
    animation: dotPulse 1.2s infinite;
}

@keyframes dotPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.3);
        opacity: 1;
    }
}

#starred-panel {
    position: absolute;
    inset: 0;
    background: var(--chat-bg);
    z-index: 6;
    display: none;
    flex-direction: column;
}

#starred-panel.on {
    display: flex;
}

.starred-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
    background: var(--chat-bg, #efeae2);
    box-sizing: border-box;
}

.starred-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    transition: transform 0.15s ease;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.starred-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.starred-card:hover {
    transform: translateY(-1px);
}

.starred-card:hover .starred-bubble {
    filter: brightness(0.97);
}

.starred-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
    font-size: 12px;
    line-height: 1.4;
}

.starred-item-author {
    font-weight: 600;
    font-size: 12.5px;
    color: var(--text-main, #111b21);
}

.starred-item-author.is-me {
    color: var(--spil-green, #0aaa51);
}

.starred-item-author.is-bot {
    color: var(--text-main, #111b21);
}

.starred-item-date {
    font-size: 11.5px;
    color: var(--text-muted, #667781);
    font-weight: 500;
    white-space: nowrap;
}

/* Styling balon pesan berbintang */
.starred-bubble {
    border-radius: 16px;
    padding: 8px 10px 7px 12px;
    box-shadow: 0 1px 2px rgba(11, 20, 26, 0.13);
    position: relative !important;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: anywhere;
    transition: filter 0.15s ease;
}

.starred-bubble.bubble-me {
    background: var(--bubble-user, #d9fdd3) !important;
    border-top-right-radius: 4px;
    align-self: flex-start;
    min-width: 86px;
}

.starred-bubble.bubble-bot {
    background: var(--bubble-bot, #ffffff) !important;
    border-top-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    align-self: flex-start;
    min-width: 78px;
}

/* Content specific sizing */
.starred-bubble.has-text-only {
    width: fit-content;
    max-width: 88%;
}

.starred-bubble.has-file {
    width: min(310px, 100%);
    max-width: 100%;
}

.starred-bubble.has-media {
    width: min(280px, 100%);
    max-width: 100%;
}

.starred-bubble.has-reply {
    width: min(320px, 100%);
    max-width: 100%;
}

/* Pratinjau gambar pada pesan berbintang */
.starred-media-box {
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 6px;
    background: rgba(0, 0, 0, 0.05);
    max-height: 160px;
    pointer-events: none;
}

.starred-media-box img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

/* Pratinjau dokumen pada pesan berbintang */
.starred-bubble .file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.04) !important;
    margin-bottom: 4px;
    color: inherit;
    text-decoration: none;
    width: 100%;
    box-sizing: border-box;
}

.starred-bubble.bubble-bot .file {
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.starred-bubble .file .ic {
    width: 38px;
    height: 42px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    flex: none;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.starred-bubble .file div {
    flex: 1;
    min-width: 0;
}

.starred-bubble .file b {
    display: block;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-main, #111b21);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Teks pesan dengan padding untuk metadata */
.starred-bubble .txt {
    font-size: 14.5px;
    color: var(--text-main, #111b21);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.starred-bubble.bubble-me .txt {
    padding-right: 74px;
}

.starred-bubble.bubble-bot .txt {
    padding-right: 60px;
}

.starred-bubble .txt.alone {
    padding-right: 0 !important;
    height: 14px !important;
}

/* Metadata di dalam balon (Ikon bintang + jam + centang) */
.starred-bubble .bubble-meta {
    position: absolute !important;
    right: 8px !important;
    bottom: 4px !important;
    display: flex !important;
    gap: 3px !important;
    align-items: center !important;
    line-height: 1 !important;
    font-size: 11px !important;
    color: var(--text-muted, #667781) !important;
    margin: 0 !important;
}

.starred-bubble .bubble-meta .star-badge {
    display: inline-flex !important;
    align-items: center !important;
    margin-right: 2px !important;
}

.starred-bubble .bubble-meta .star-badge svg {
    width: 12px !important;
    height: 12px !important;
    fill: #e5a100 !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.starred-bubble .bubble-meta .tk {
    display: inline-flex !important;
    align-items: center !important;
}

.starred-bubble .bubble-meta .tk svg {
    width: 15px !important;
    height: 15px !important;
    fill: currentColor !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.starred-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bubble-bot);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 0.15s, transform 0.15s;
    text-align: left;
    width: 100%;
}

.starred-item:hover {
    background: #f7faf8;
}

.starred-item .item-content {
    flex: 1;
    min-width: 0;
}

.starred-item .item-author {
    display: block;
    color: var(--spil-green);
    font-size: 13px;
    font-weight: 600;
}

.starred-item .item-text {
    margin-top: 3px;
    font-size: 13.5px;
    color: var(--text-main);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.starred-item .item-time {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 11.5px;
}

.starred-item .btn-unstar-item {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #e5a100;
    opacity: 0.85;
    transition: opacity 0.15s, transform 0.15s, background 0.15s;
}

.starred-item .btn-unstar-item:hover {
    opacity: 1;
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.05);
}

.starred-item .btn-unstar-item svg {
    width: 18px;
    height: 18px;
}

.starred-empty {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    padding: 24px 16px;
    font-size: 13.5px;
    max-width: 280px;
    line-height: 1.45;
}

.starred-empty svg {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    fill: var(--text-muted);
    opacity: 0.45;
}

/* Tombol coba kirim ulang pada pesan gagal (Opsi A: footer sejajar responsif tanpa bertabrakan dengan jam & status) */
#myspil-chat-wrapper .me .bubble.has-retry {
    min-width: min(248px, 84%);
}

#myspil-chat-wrapper .me .bubble.has-retry.has-star {
    min-width: min(264px, 84%);
}

#myspil-chat-wrapper .bubble.has-retry .txt.alone {
    display: none;
}

#myspil-chat-wrapper .bubble.has-video.has-retry .txt:not(.alone) {
    padding-bottom: 0;
}

.msg-retry-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 6px;
    row-gap: 2px;
    margin-top: 5px;
    padding-top: 4px;
    padding-right: 64px;
    border-top: 1px dashed rgba(229, 72, 77, 0.3);
    font-size: 11.5px;
    color: #e5484d;
    line-height: 1.3;
}

#myspil-chat-wrapper .bubble.has-star .msg-retry-wrap {
    padding-right: 80px;
}

.msg-retry-wrap .msg-retry-text {
    color: #e5484d;
    font-weight: 500;
}

.msg-retry-wrap .btn-msg-retry {
    background: none;
    border: none;
    color: var(--spil-green);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.msg-retry-wrap .btn-msg-retry:hover {
    opacity: 0.8;
}

/* Penyesuaian responsif layar tablet & seluler untuk tumpukan 3 floating button */
@media (max-width: 768px) {
    #chatbot-gif {
        bottom: 76px !important;
        right: -20px !important;
    }
    #chat-fab {
        bottom: 182px;
        right: 15px;
    }
}

/* Penyesuaian responsif layar seluler */
@media (max-width: 480px) {
    #myspil-chat-wrapper {
        bottom: 12px;
        right: 12px;
    }
    #chatbotmenu {
        bottom: 12px !important;
        right: 12px !important;
    }
    #chatbot-gif {
        bottom: 74px !important;
        right: -20px !important;
    }
    #chat-window {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 50px);
        margin-bottom: 10px;
        border-radius: 18px;
    }
    #chat-fab {
        bottom: 180px;
        right: 12px;
        width: 54px;
        height: 54px;
    }
    #chat-fab .chat-fab-icon-img {
        width: 54px;
        height: 54px;
    }
    #chat-fab.fab-fallback-active {
        width: 52px;
        height: 52px;
        font-size: 24px;
    }
    #myspil-chat-wrapper textarea {
        font-size: 15px; /* Prevents unwanted auto-zoom on iOS Safari */
    }
}

/* =========================================================================
   Indikator Animasi Mengetik
   ========================================================================= */
#myspil-chat-wrapper .message-row.typing .bubble {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 12px 14px !important;
    min-width: 52px;
    background: var(--bubble-bot);
    border-top-left-radius: 4px;
    box-shadow: var(--shadow);
}

#myspil-chat-wrapper .message-row.typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    display: inline-block;
    animation: myspil-typing 1s infinite;
}

#myspil-chat-wrapper .message-row.typing i:nth-child(2) {
    animation-delay: 0.15s;
}

#myspil-chat-wrapper .message-row.typing i:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes myspil-typing {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #myspil-chat-wrapper .message-row.typing i {
        animation: none;
    }
}

/* ==========================================================================
   Notifikasi Toast Pesan Masuk
   ========================================================================== */

#chat-toast-container {
    position: fixed;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
    pointer-events: none;
    box-sizing: border-box;
}

#chat-toast-container.toast-pos-top-right {
    top: calc(20px + env(safe-area-inset-top, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
}

#chat-toast-container.toast-pos-bottom-right {
    bottom: calc(85px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
}

#chat-toast-container.toast-pos-top-left {
    top: calc(20px + env(safe-area-inset-top, 0px));
    left: calc(20px + env(safe-area-inset-left, 0px));
}

#chat-toast-container.toast-pos-bottom-left {
    bottom: calc(85px + env(safe-area-inset-bottom, 0px));
    left: calc(20px + env(safe-area-inset-left, 0px));
}

.chat-toast {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    background: #ffffff;
    color: var(--text-main, #111b21);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--spil-green, #0aaa51);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(10, 25, 40, 0.16);
    padding: 12px 14px 14px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 4px 12px;
    align-items: start;
    box-sizing: border-box;
    transition: transform 0.2s ease, opacity 0.2s ease;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-toast.toast-entering {
    animation: toastSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chat-toast.toast-dismissing {
    animation: toastSlideOut 0.2s ease-in forwards;
}

.chat-toast .toast-avatar {
    grid-row: span 3;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--spil-green, #0aaa51);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
    position: relative;
}

.chat-toast .toast-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.chat-toast .toast-avatar .avatar-fallback {
    z-index: 1;
}

.chat-toast .toast-header {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.chat-toast .toast-sender {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text-main, #111b21);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-toast .toast-count-badge {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    background: rgba(10, 170, 81, 0.1);
    color: var(--spil-green, #0aaa51);
    border: 1px solid rgba(10, 170, 81, 0.22);
    padding: 2px 8px;
    border-radius: 9999px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.chat-toast .toast-time {
    font-size: 11px;
    color: var(--text-muted, #667781);
    margin-left: auto;
    flex-shrink: 0;
}

#myspil-chat-wrapper .chat-toast .toast-btn-close,
.chat-toast .toast-btn-close {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    width: 26px;
    height: 26px;
    margin: -3px -3px 0 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #8c9ba5;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

#myspil-chat-wrapper .chat-toast .toast-btn-close:hover,
.chat-toast .toast-btn-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-main, #111b21);
}

#myspil-chat-wrapper .chat-toast .toast-btn-close:active,
.chat-toast .toast-btn-close:active {
    transform: scale(0.9);
}

#myspil-chat-wrapper .chat-toast .toast-btn-close svg,
.chat-toast .toast-btn-close svg {
    width: 12px !important;
    height: 12px !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    fill: none !important;
}

.chat-toast .toast-body {
    grid-column: 2 / 4;
    font-size: 13px;
    line-height: 1.45;
    color: #2c3e50;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    transition: opacity 0.15s ease;
}

.chat-toast .toast-actions {
    grid-column: 2 / 4;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 6px; /* Margin of safety from bottom progress bar */
}

#myspil-chat-wrapper #chat-toast-container .toast-btn-reply,
#myspil-chat-wrapper .chat-toast .toast-btn-reply,
.chat-toast .toast-btn-reply {
    border-radius: 9999px !important;
    padding: 6px 18px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    border: 1px solid var(--spil-green, #0aaa51) !important;
    background: var(--spil-green, #0aaa51) !important;
    background-color: var(--spil-green, #0aaa51) !important;
    color: #ffffff !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 32px !important;
    box-shadow: 0 2px 6px rgba(10, 170, 81, 0.28) !important;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease !important;
    user-select: none !important;
}

#myspil-chat-wrapper #chat-toast-container .toast-btn-reply:hover,
#myspil-chat-wrapper .chat-toast .toast-btn-reply:hover,
.chat-toast .toast-btn-reply:hover {
    background: var(--spil-green-hover, #088c42) !important;
    background-color: var(--spil-green-hover, #088c42) !important;
    border-color: var(--spil-green-hover, #088c42) !important;
    box-shadow: 0 4px 12px rgba(10, 170, 81, 0.38) !important;
    transform: translateY(-1px) !important;
}

#myspil-chat-wrapper #chat-toast-container .toast-btn-reply:active,
#myspil-chat-wrapper .chat-toast .toast-btn-reply:active,
.chat-toast .toast-btn-reply:active {
    transform: scale(0.96) !important;
    box-shadow: 0 1px 3px rgba(10, 170, 81, 0.2) !important;
}

#myspil-chat-wrapper #chat-toast-container .toast-btn-reply:focus-visible,
#myspil-chat-wrapper .chat-toast .toast-btn-reply:focus-visible,
.chat-toast .toast-btn-reply:focus-visible {
    outline: 2px solid var(--spil-green, #0aaa51) !important;
    outline-offset: 2px !important;
}

.chat-toast .toast-progress-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--spil-green, #0aaa51);
    transform-origin: left;
    animation: toastProgressBar var(--toast-dur, 6000ms) linear forwards;
}

.chat-toast:hover .toast-progress-bar,
.chat-toast:focus-within .toast-progress-bar,
.chat-toast.toast-paused .toast-progress-bar {
    animation-play-state: paused !important;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#chat-toast-container.toast-pos-top-left .chat-toast.toast-entering,
#chat-toast-container.toast-pos-bottom-left .chat-toast.toast-entering {
    animation-name: toastSlideInLeft;
}

@keyframes toastSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

#chat-toast-container.toast-pos-top-left .chat-toast.toast-dismissing,
#chat-toast-container.toast-pos-bottom-left .chat-toast.toast-dismissing {
    animation-name: toastSlideOutLeft;
}

@keyframes toastSlideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

@keyframes toastProgressBar {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-toast.toast-entering,
    .chat-toast.toast-dismissing {
        animation: none !important;
    }
    .chat-toast .toast-progress-bar {
        animation-duration: var(--toast-dur, 6000ms);
    }
}

/* Tata letak responsif untuk perangkat mobile */
@media (max-width: 480px) {
    #chat-toast-container {
        width: calc(100vw - 20px);
    }
    #chat-toast-container.toast-pos-top-right,
    #chat-toast-container.toast-pos-top-left {
        top: calc(10px + env(safe-area-inset-top, 0px));
        right: 10px;
        left: 10px;
    }
    #chat-toast-container.toast-pos-bottom-right,
    #chat-toast-container.toast-pos-bottom-left {
        bottom: calc(75px + env(safe-area-inset-bottom, 0px));
        right: 10px;
        left: 10px;
    }
    .chat-toast {
        padding: 10px 12px 12px;
        gap: 3px 10px;
    }
    .chat-toast .toast-btn-reply {
        min-height: 36px;
        padding: 6px 18px;
    }
    .chat-toast .toast-btn-close {
        width: 32px;
        height: 32px;
    }
}

/* =========================================================================
   Modal Survey Penilaian Layanan Chat (Closed Case)
   ========================================================================= */
#myspil-chat-wrapper .survey-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s cubic-bezier(0.2, 0.8, 0.3, 1), visibility 0.24s;
}

#myspil-chat-wrapper .survey-overlay.on {
    opacity: 1;
    visibility: visible;
}

#myspil-chat-wrapper .survey-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 24px 22px 20px;
    width: calc(100% - 32px);
    max-width: 340px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
    transform: scale(0.92);
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
    box-sizing: border-box;
}

#myspil-chat-wrapper .survey-overlay.on .survey-card {
    transform: scale(1);
}

#myspil-chat-wrapper .survey-title {
    color: var(--spil-green);
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 18px 0;
}

#myspil-chat-wrapper .survey-q-item {
    margin-bottom: 14px;
}

#myspil-chat-wrapper .survey-q-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    display: block;
}

#myspil-chat-wrapper .survey-options-row {
    display: flex;
    gap: 12px;
}

#myspil-chat-wrapper .survey-option-btn {
    flex: 1;
    height: 48px;
    min-height: 48px;
    border-radius: 12px;
    background: #f1f3f4;
    border: 1.5px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    color: var(--text-muted);
}

#myspil-chat-wrapper .survey-option-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    transition: transform 0.15s ease, fill 0.2s ease;
}

#myspil-chat-wrapper .survey-option-btn:hover {
    background: #e8eaed;
}

#myspil-chat-wrapper .survey-option-btn:active svg {
    transform: scale(0.9);
}

/* Opsi GOOD dipilih (Hijau) */
#myspil-chat-wrapper .survey-option-btn.selected-good {
    background: #e8f5e9 !important;
    border-color: var(--spil-green) !important;
    color: var(--spil-green) !important;
}

/* Opsi BAD dipilih (Merah) */
#myspil-chat-wrapper .survey-option-btn.selected-bad {
    background: #fce8e6 !important;
    border-color: #ea4335 !important;
    color: #ea4335 !important;
}

/* Field input saran */
#myspil-chat-wrapper .survey-feedback-wrap {
    margin: 18px 0 20px;
}

#myspil-chat-wrapper .survey-feedback-input {
    width: 100%;
    border: none;
    border-bottom: 1.5px solid #dadce0;
    border-radius: 0;
    padding: 6px 0;
    font-size: 13.5px;
    color: var(--text-main);
    background: transparent;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

#myspil-chat-wrapper .survey-feedback-input:focus {
    border-bottom-color: var(--spil-green);
}

#myspil-chat-wrapper .survey-feedback-input::placeholder {
    color: var(--text-muted);
    font-size: 13px;
}

/* Tombol aksi (Later & Submit) */
#myspil-chat-wrapper .survey-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

#myspil-chat-wrapper .btn-survey-later {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

#myspil-chat-wrapper .btn-survey-later:hover {
    color: var(--text-main);
    background: #f1f3f4;
}

#myspil-chat-wrapper .btn-survey-submit {
    background: var(--spil-green);
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 22px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(10, 170, 81, 0.32);
    transition: all 0.2s ease;
}

#myspil-chat-wrapper .btn-survey-submit:hover:not(:disabled) {
    background: var(--spil-green-hover);
    box-shadow: 0 4px 12px rgba(10, 170, 81, 0.4);
}

#myspil-chat-wrapper .btn-survey-submit:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}



