/* ================================================================
   ASISTEN CS IN-APP (widget chat mengambang)
   Panel chat TETAP dark mode indigo — tidak mengikuti tema aplikasi.
   FAB memakai gaya kaca transparan (mengikuti tombol Tambah Kolam/
   Tambah Siklus); warna ikon menyesuaikan tema agar kontras.
   ================================================================ */

/* ----- Tombol mengambang (FAB) ----- */
#cs-fab {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 950;
    box-sizing: border-box;
    width: 44px;                     /* lebih kecil dari sebelumnya (56px) */
    height: 44px;
    border: 1px solid rgba(79, 70, 229, 0.35);
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.15);   /* kaca transparan */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #4f46e5;                  /* mode terang: ikon indigo pekat */
    font-size: 18px;
    cursor: grab;                    /* bisa digeser ke segala arah */
    touch-action: none;              /* drag di layar sentuh tidak ikut men-scroll */
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
                background 0.15s ease, border-color 0.15s ease;
}

/* Mode gelap: ikon indigo muda supaya kontras di atas latar gelap */
[data-theme="dark"] #cs-fab {
    color: #a5b4fc;
}

/* Halaman berlatar gelap tanpa atribut data-theme (mis. simulator) —
   kelas dipasang oleh cs-widget.js berdasarkan kecerahan latar */
#cs-fab.cs-ikon-terang {
    color: #a5b4fc;
}

#cs-fab:hover {
    transform: translateY(-2px);
    background: rgba(79, 70, 229, 0.25);
    border-color: rgba(79, 70, 229, 0.5);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.3);
}

/* Saat digeser — kursor genggam & angkat sedikit */
#cs-fab.cs-dragging {
    cursor: grabbing;
    transform: scale(1.05);
    transition: none;
    background: rgba(79, 70, 229, 0.3);
    border-color: rgba(79, 70, 229, 0.5);
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.35);
}

/* ----- Panel chat ----- */
#cs-panel {
    position: fixed;
    right: 20px;
    bottom: 80px;                    /* jatuh tepat di atas FAB 44px (CSS cadangan; JS menempatkan presisi) */
    z-index: 951;
    width: min(360px, calc(100vw - 32px));
    height: min(480px, calc(100vh - 140px));
    height: min(480px, calc(100dvh - 140px)); /* dvh: ikut tinggi riil saat bar alamat menyusut */
    /* Catatan: saat dibuka, JS menimpa lebar/tinggi ini agar pas
       dengan sisa ruang di sekitar tombol & kapasitas layar. */
    background: #11162b;
    border: 1px solid #2a3352;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#cs-panel.cs-terbuka {
    display: flex;
}

/* ----- Header ----- */
#cs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #4f46e5, #3730a3);
    color: #fff;
}

#cs-header .cs-judul {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}

.cs-voice-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    color: #e0e7ff;
    white-space: nowrap;
}
.cs-voice-status.cs-voice-aktif {
    background: rgba(16,185,129,0.25);
    color: #d1fae5;
}

#cs-tutup {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}

#cs-tutup:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ----- Area pesan ----- */
#cs-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #0d1324;
}

.cs-pesan {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    animation: cs-muncul 0.15s ease;
}

@keyframes cs-muncul {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cs-pesan.cs-bot {
    align-self: flex-start;
    background: #1a2138;
    border: 1px solid #2a3352;
    border-bottom-left-radius: 4px;
    color: #dbe1f0;
}

.cs-pesan.cs-user {
    align-self: flex-end;
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Indikator "sedang mengetik" */
.cs-mengetik {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 11px 14px;
    background: #1a2138;
    border: 1px solid #2a3352;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.cs-mengetik span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #818cf8;
    animation: cs-kedip 1s infinite;
}

.cs-mengetik span:nth-child(2) { animation-delay: 0.2s; }
.cs-mengetik span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cs-kedip {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;    transform: translateY(-3px); }
}

/* ----- Saran topik (chips) ----- */
#cs-saran {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px 0;
    background: #0d1324;
}

.cs-chip {
    border: 1px solid #4f46e5;
    background: #1a2138;
    color: #a5b4fc;
    font-size: 12.5px;
    padding: 5px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.cs-chip:hover {
    background: rgba(79, 70, 229, 0.25);
}

.cs-aksi {
    align-self: flex-start;
    padding: 0 2px;
}
.cs-aksi-btn {
    border: 1px solid #4f46e5;
    background: #4f46e5;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
}
.cs-aksi-btn:hover { background: #6366f1; }
.cs-aksi-btn:disabled { opacity: 0.65; cursor: not-allowed; }
.cs-aksi-info { font-size: 12px; color: #94a3b8; margin-top: 4px; }

/* In-app page viewer */
#cs-viewer {
    position: fixed; inset: 0; z-index: 1200; display: none;
    background: rgba(15, 23, 42, 0.55);
}
#cs-viewer.cs-terbuka { display: flex; align-items: center; justify-content: center; padding: 16px; }
#cs-viewer-box {
    width: min(1100px, 96vw); height: min(86vh, 900px);
    background: #0f172a; border: 1px solid #2a3352; border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.45); display: flex; flex-direction: column; overflow: hidden;
}
#cs-viewer-head {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    background: #11162b; border-bottom: 1px solid #2a3352; color: #e5e7eb;
}
#cs-viewer-title { font-size: 14px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-viewer-btn {
    border: 1px solid #2a3352; background: #1a2138; color: #dbe1f0;
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
}
.cs-viewer-btn:hover { background: rgba(79,70,229,.25); }
#cs-viewer-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ----- Input pesan ----- */
#cs-form {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: #11162b;
    border-top: 1px solid #2a3352;
}

#cs-input {
    flex: 1;
    border: 1px solid #2a3352;
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 14px;
    background: #0d1324;
    color: #e5e7eb;
    outline: none;
}

#cs-input::placeholder {
    color: #7b87ad;
}

#cs-input:focus {
    border-color: #818cf8;
}

#cs-kirim {
    border: none;
    background: #4f46e5;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cs-kirim:hover {
    background: #6366f1;
}

#cs-kirim:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#cs-mic {
    border: 1px solid #2a3352;
    background: #1a2138;
    color: #a5b4fc;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#cs-mic:hover {
    background: rgba(79, 70, 229, 0.25);
}
#cs-mic.cs-mic-aktif {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}
#cs-mic[hidden] { display: none !important; }

/* ----- Scrollbar tipis ----- */
#cs-log::-webkit-scrollbar {
    width: 6px;
}

#cs-log::-webkit-scrollbar-thumb {
    background: #2a3352;
    border-radius: 3px;
}

/* ----- Layar lebar: card sedikit lebih besar ----- */
@media (min-width: 1024px) {
    #cs-panel {
        width: min(420px, calc(100vw - 40px));
        height: min(540px, calc(100vh - 160px));
        height: min(540px, calc(100dvh - 160px));
    }
}

/* ----- Layar kecil ----- */
@media (max-width: 480px) {
    #cs-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 76px;                /* di atas FAB 44px (cadangan; JS presisi) */
    }

    #cs-fab {
        right: 16px;
        bottom: 20px;
    }
}
