/**
 * LK21 on-site chat — drawer + FAB. Read-only mirror of @lk21mobile group.
 * See docs/telegram-chat.md.
 */

.lk21-chat-wrap {
    position: fixed;
    inset: 0;
    pointer-events: none;
    /* Stay above lh-fs-stage (z-index 9990) so the panel + FAB are
     * usable while the live-player overlay is open. */
    z-index: 9995;
}
.lk21-chat-wrap > * { pointer-events: auto; }

/* ── Floating Action Button ────────────────────────────────────────── */
.lk21-chat-fab {
    position: fixed;
    bottom: 18px;
    right: 18px;
    height: 50px;
    padding: 0 18px 0 14px;
    border-radius: 25px;
    background: linear-gradient(135deg, #0088cc, #1f6feb);
    border: none;
    color: #fff;
    font: 600 14px/1 system-ui, sans-serif;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,136,204,0.45), 0 2px 6px rgba(0,0,0,0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform .2s ease, box-shadow .2s ease, opacity .25s ease;
    animation: lk21-chat-fab-pop 4s ease-in-out infinite;
}
/* Hide FAB whenever the live-player overlay is open — the in-player
 * top-bar 💬 Diskusi button is the only entry inside playback so we
 * don't show two redundant chat triggers. Also hidden when the panel
 * itself is already open. */
body:has(#lh-fs-stage.is-open) .lk21-chat-fab,
body.lk21-chat-open .lk21-chat-fab {
    opacity: 0;
    pointer-events: none;
}
.lk21-chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,136,204,0.55), 0 3px 8px rgba(0,0,0,0.35); }
.lk21-chat-fab.is-active {
    animation: lk21-chat-fab-pulse 1.4s ease-in-out infinite;
}
@keyframes lk21-chat-fab-pulse {
    0%   { box-shadow: 0 6px 20px rgba(0,136,204,0.45), 0 2px 6px rgba(0,0,0,0.3), 0 0 0 0 rgba(34,197,94,0.55); }
    70%  { box-shadow: 0 6px 20px rgba(0,136,204,0.45), 0 2px 6px rgba(0,0,0,0.3), 0 0 0 12px rgba(34,197,94,0); }
    100% { box-shadow: 0 6px 20px rgba(0,136,204,0.45), 0 2px 6px rgba(0,0,0,0.3), 0 0 0 0 rgba(34,197,94,0); }
}
.lk21-chat-fab-emoji { font-size: 19px; line-height: 1; }
.lk21-chat-fab-label { letter-spacing: 0.2px; }
.lk21-chat-fab-badge {
    background: #ef4444;
    color: #fff;
    font: 700 11px/1 system-ui, sans-serif;
    padding: 3px 7px;
    border-radius: 999px;
    margin-left: 4px;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
}
@keyframes lk21-chat-fab-pop {
    0%, 96%, 100% { transform: translateY(0); }
    98%           { transform: translateY(-3px); }
}
@media (max-width: 720px) {
    .lk21-chat-fab { bottom: 14px; right: 14px; height: 46px; padding: 0 14px 0 12px; font-size: 13px; }
    .lk21-chat-fab-label { display: none; }
}

/* ── Panel (drawer / bottom-sheet) ─────────────────────────────────── */
.lk21-chat-panel {
    position: fixed;
    top: 0; right: 0;
    width: min(380px, 92vw);
    height: 100vh;
    background: #1a1a1d;
    color: #e8e8eb;
    box-shadow: -8px 0 30px rgba(0,0,0,0.5);
    transform: translateX(100%);
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
    z-index: 9996;
    pointer-events: auto;
}
.lk21-chat-panel.is-open { transform: translateX(0); }

/* Side-mode (mode B): chat docks alongside the live-player overlay,
 * shrinking the player so the video stays fully visible. Float mode
 * stays the default — chat slides over the right 380px of viewport. */
body.lk21-chat-mode-side.lk21-chat-open #lh-fs-stage .lh-fs-video-wrap {
    width: calc(100% - 380px);
    transition: width .25s ease;
}
body.lk21-chat-mode-side.lk21-chat-open #lh-fs-stage video,
body.lk21-chat-mode-side.lk21-chat-open #lh-fs-stage .nb-iframe-wrap {
    width: 100%;
}
@media (max-width: 720px) {
    /* Mobile collapses mode B to bottom-sheet — the wrap shrink would
     * leave a useless ~80px-wide sliver of video. */
    body.lk21-chat-mode-side.lk21-chat-open #lh-fs-stage .lh-fs-video-wrap {
        width: 100%;
    }
}
@media (max-width: 720px) {
    .lk21-chat-panel {
        width: 100vw;
        height: 75vh;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    .lk21-chat-panel.is-open { transform: translateY(0); }
}

.lk21-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, #232328 0%, #1a1a1d 100%);
}
.lk21-chat-head-title { display: inline-flex; align-items: center; gap: 8px; font: 700 15px/1.2 system-ui, sans-serif; }
.lk21-chat-head-emoji { font-size: 18px; }
.lk21-chat-head-actions { display: inline-flex; gap: 4px; align-items: center; }
.lk21-chat-head-tg, .lk21-chat-close, .lk21-chat-mode-toggle {
    color: #fff;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}
.lk21-chat-head-tg:hover, .lk21-chat-close:hover, .lk21-chat-mode-toggle:hover { background: rgba(56,189,248,0.25); }
@media (max-width: 720px) {
    /* Mode toggle is desktop-only — sheet mode has no side equivalent. */
    .lk21-chat-mode-toggle { display: none; }
}

.lk21-chat-banner {
    padding: 10px 16px;
    background: rgba(0,136,204,0.12);
    border-bottom: 1px solid rgba(0,136,204,0.3);
    color: #cfe9ff;
    font: 500 12.5px/1.4 system-ui, sans-serif;
}
.lk21-chat-banner strong { color: #fff; }

.lk21-chat-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.lk21-chat-list::-webkit-scrollbar { width: 8px; }
.lk21-chat-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.lk21-chat-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.lk21-chat-avatar {
    flex: 0 0 auto;
    width: 32px; height: 32px;
    border-radius: 50%;
    color: #fff;
    font: 700 13px/1 system-ui, sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}
.lk21-chat-body { flex: 1 1 auto; min-width: 0; }
.lk21-chat-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font: 600 12.5px/1.2 system-ui, sans-serif;
    margin-bottom: 2px;
}
.lk21-chat-name { color: #fff; }
.lk21-chat-time { color: rgba(255,255,255,0.45); font-size: 11px; font-weight: 500; }
.lk21-chat-text {
    font: 400 14px/1.45 system-ui, sans-serif;
    color: #d4d4d8;
    word-break: break-word;
}
.lk21-chat-text a { color: #38bdf8; text-decoration: none; }
.lk21-chat-text a:hover { text-decoration: underline; }
.lk21-chat-quick-reply {
    display: inline-block;
    margin-top: 4px;
    font: 500 11.5px/1 system-ui, sans-serif;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}
.lk21-chat-quick-reply:hover { color: #fff; border-color: rgba(56,189,248,0.5); background: rgba(56,189,248,0.12); }

.lk21-chat-empty {
    color: rgba(255,255,255,0.55);
    text-align: center;
    padding: 32px 18px;
    font: 400 13.5px/1.5 system-ui, sans-serif;
}
.lk21-chat-empty-link { color: #38bdf8; text-decoration: none; font-weight: 600; }

.lk21-chat-foot {
    flex: 0 0 auto;
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: #16161a;
}
.lk21-chat-cta {
    display: block;
    text-align: center;
    background: linear-gradient(135deg, #0088cc, #1f6feb);
    color: #fff;
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 10px;
    font: 700 14px/1.2 system-ui, sans-serif;
    box-shadow: 0 4px 12px rgba(0,136,204,0.35);
}
.lk21-chat-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,136,204,0.45); }
