/* ============================================================
   Tanya Janes — widget chatbot (parts/_janes.php, js/janes.js)
   Memakai token warna tema (sitaka-base.css / sitaka-dark.css).
   ============================================================ */
.janes { --janes-edge: 20px; }

/* ---------- tombol pembuka ---------- */
.janes-fab {
  position: fixed; right: var(--janes-edge); bottom: calc(var(--janes-edge) + env(safe-area-inset-bottom, 0px)); z-index: 1001;
  display: flex; align-items: center; gap: 0; padding: 0; border: 0; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.janes-fab__img {
  width: 68px; height: 68px; border-radius: 50%; display: block; position: relative; z-index: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 34, 68, 0.35)); transition: transform .25s ease;
  animation: janes-hai 1.2s ease 1.5s 2;
}
.janes-fab:hover .janes-fab__img, .janes-fab:focus-visible .janes-fab__img { transform: scale(1.06) rotate(-4deg); }
.janes-fab__label {
  margin-right: -14px; padding: 9px 24px 9px 16px; border-radius: 9999px 0 0 9999px;
  background: var(--cj-navy); color: #fff; font-family: var(--cj-font-head); font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 34, 68, 0.3);
}
.janes-fab__label b { color: var(--cj-gold); font-weight: 800; }
.janes-fab:focus-visible { outline: none; }
.janes-fab:focus-visible .janes-fab__label { outline: 3px solid var(--cj-gold); outline-offset: 2px; }
.janes.is-open .janes-fab__label { display: none; }
@keyframes janes-hai { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(8deg); } }
@media (max-width: 575.98px) {
  .janes { --janes-edge: 14px; }
  .janes-fab__img { width: 58px; height: 58px; }
  .janes-fab__label { font-size: 13px; padding: 7px 20px 7px 12px; }
  .janes.is-open .janes-fab { display: none; }
}

/* ---------- panel ---------- */
.janes-panel {
  position: fixed; right: var(--janes-edge); bottom: calc(var(--janes-edge) + 80px); z-index: 1045;
  width: 380px; height: min(600px, calc(100vh - 120px)); display: flex; flex-direction: column;
  background: var(--cj-surface); color: var(--cj-ink); border: 1px solid var(--cj-line); border-radius: 20px; overflow: hidden;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28); animation: janes-masuk .22s ease-out;
}
.janes-panel[hidden] { display: none; }
@keyframes janes-masuk { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 575.98px) {
  .janes-panel { right: 0; left: 0; bottom: 0; width: auto; height: 88vh; height: 88dvh; border-radius: 20px 20px 0 0; border-bottom: 0; }
}

.janes-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; flex: none;
  background: linear-gradient(135deg, var(--cj-navy) 0%, #0B4F8F 100%); color: #fff;
}
.janes-head__img { width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.janes-head__txt { flex: 1; min-width: 0; }
.janes-head__title { margin: 0; font-family: var(--cj-font-head); font-size: 16px; font-weight: 800; color: #fff; line-height: 1.2; }
.janes-head__sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(255, 255, 255, .78); }
.janes-dot { width: 8px; height: 8px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); }
.janes-icon {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; transition: background .2s;
}
.janes-icon:hover, .janes-icon:focus-visible { background: rgba(255, 255, 255, .22); outline: none; }

.janes-body {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px;
  background: var(--cj-surface-alt); overscroll-behavior: contain;
}
.janes-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.janes-msg.is-new { animation: janes-masuk .2s ease-out; }
.janes-msg__ava { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.janes-msg__bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere;
}
.janes-msg--bot .janes-msg__bubble { background: var(--cj-surface); border: 1px solid var(--cj-line); border-bottom-left-radius: 4px; color: var(--cj-ink); }
.janes-msg--user { justify-content: flex-end; }
.janes-msg--user .janes-msg__bubble { background: var(--cj-navy); color: #fff; border-bottom-right-radius: 4px; }
.janes-msg__bubble p { margin: 0; }
.janes-msg__bubble p + p, .janes-msg__bubble p + ul, .janes-msg__bubble ul + p { margin-top: 8px; }
.janes-msg__bubble ul { margin: 4px 0 0; padding-left: 18px; }
.janes-msg__bubble li + li { margin-top: 3px; }
.janes-msg__bubble a { color: var(--cj-blue); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.janes-msg__bubble b { color: var(--cj-ink-strong); }

.janes-typing .janes-msg__bubble { display: flex; gap: 4px; padding: 13px 14px; }
.janes-typing .janes-msg__bubble span { width: 7px; height: 7px; border-radius: 50%; background: var(--cj-muted-soft); animation: janes-ketik 1s infinite ease-in-out; }
.janes-typing .janes-msg__bubble span:nth-child(2) { animation-delay: .15s; }
.janes-typing .janes-msg__bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes janes-ketik { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.janes-chips {
  flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 10px; max-height: 132px; overflow-y: auto;
  background: var(--cj-surface-alt); border-top: 1px solid var(--cj-line-soft);
}
.janes-chips[hidden] { display: none; }
.janes-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9999px; cursor: pointer;
  border: 1px solid rgba(var(--cj-navy-rgb), .25); background: var(--cj-surface); color: var(--cj-navy);
  font-size: 13px; font-weight: 600; line-height: 1.2; text-decoration: none !important; transition: background .15s, color .15s;
}
.janes-chip:hover, .janes-chip:focus-visible { background: var(--cj-navy); color: #fff; outline: none; }
.janes-chip--wa { border-color: #25D366; color: #128C4A; }
.janes-chip--wa:hover, .janes-chip--wa:focus-visible { background: #25D366; color: #fff; }
.janes-chip--ghost { border-style: dashed; color: var(--cj-muted); }

/* bilah "Chat pustakawan" di bawah kepala panel */
.janes-wa { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 14px; background: rgba(37, 211, 102, .08); border-bottom: 1px solid var(--cj-line); }
.janes-wa[hidden] { display: none; }
.janes-wa a { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #128C4A; text-decoration: none; }
.janes-wa a:hover, .janes-wa a:focus-visible { text-decoration: underline; }
.janes-wa a i { font-size: 16px; }
.janes-wa__jam { flex: 1 1 100%; font-size: 11.5px; color: var(--cj-muted); line-height: 1.4; }

.janes-form { flex: none; display: flex; gap: 8px; padding: 10px 12px 4px; background: var(--cj-surface); border-top: 1px solid var(--cj-line); }
.janes-form input {
  flex: 1; min-width: 0; height: 42px; padding: 0 14px; border: 1px solid var(--cj-line); border-radius: 9999px;
  background: var(--cj-surface-alt); color: var(--cj-ink); font-size: 14px;
}
.janes-form input:focus { outline: none; border-color: var(--cj-gold); box-shadow: 0 0 0 3px rgba(var(--cj-gold-rgb), .25); }
.janes-send {
  flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--cj-gold); color: var(--cj-navy); display: grid; place-items: center; transition: transform .15s;
}
.janes-send:hover { transform: scale(1.06); }
.janes-note { margin: 0; padding: 4px 14px 10px; font-size: 11px; color: var(--cj-muted); background: var(--cj-surface); text-align: center; }

/* mode gelap */
:root[data-theme="dark"] .janes-panel { box-shadow: 0 20px 50px rgba(0, 0, 0, .6); }
:root[data-theme="dark"] .janes-msg--user .janes-msg__bubble { background: #1D4E89; }
:root[data-theme="dark"] .janes-chip { color: #CFE2F7; border-color: rgba(127, 178, 232, .35); }
:root[data-theme="dark"] .janes-chip:hover, :root[data-theme="dark"] .janes-chip:focus-visible { background: #1D4E89; color: #fff; }
:root[data-theme="dark"] .janes-chip--wa, :root[data-theme="dark"] .janes-wa a { color: #4ADE80; border-color: rgba(37, 211, 102, .5); }
:root[data-theme="dark"] .janes-msg__bubble a { color: #8FC0F0; }

@media (prefers-reduced-motion: reduce) {
  .janes-fab__img, .janes-panel, .janes-msg.is-new, .janes-typing .janes-msg__bubble span { animation: none; }
}
