/* Cybrarians Journal chatbot widget — all selectors prefixed cjb- to stay
   clear of the OJS theme (Bootstrap-ish). Brand: #0172BE (journal accent). */

.cjb-launcher,
.cjb-panel,
.cjb-panel * { box-sizing: border-box; }

.cjb-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: #0172be;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(1, 114, 190, 0.45);
  transition: transform 0.15s ease, background 0.15s ease;
  padding: 0;
}
.cjb-launcher:hover { background: #015b98; transform: translateY(-2px); }
.cjb-launcher:focus-visible { outline: 3px solid #7fc4f2; outline-offset: 2px; }

.cjb-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 2147483001;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(560px, calc(100vh - 130px));
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1c2733;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.cjb-panel.cjb-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
}

.cjb-head {
  background: #0172be;
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cjb-headtxt { flex: 1; min-width: 0; }
.cjb-title { display: block; font-size: 15px; font-weight: 700; }
.cjb-sub { display: block; font-size: 11.5px; opacity: 0.85; }
.cjb-headbtns { display: flex; gap: 4px; }
.cjb-icbtn {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  border-radius: 8px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}
.cjb-icbtn:hover { background: rgba(255, 255, 255, 0.28); }

.cjb-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f6f9fc;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.cjb-msg { display: flex; }
.cjb-msg.cjb-bot { justify-content: flex-start; }
.cjb-msg.cjb-user { justify-content: flex-end; }
.cjb-bubble {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #dde7f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  overflow-wrap: anywhere;
}
.cjb-user .cjb-bubble {
  background: #0172be;
  border-color: #0172be;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cjb-bot .cjb-bubble { border-bottom-left-radius: 4px; }
[dir="rtl"] .cjb-user .cjb-bubble { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }

.cjb-text { margin-bottom: 6px; }

.cjb-src {
  border-inline-start: 3px solid #0172be;
  background: #eef6fc;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 8px;
}
.cjb-srct {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: #015b98;
  text-decoration: none;
  margin-bottom: 3px;
}
.cjb-srct:hover { text-decoration: underline; }
.cjb-srctxt { margin: 0; font-size: 13px; color: #33414f; }

.cjb-intro { margin-top: 8px; font-weight: 600; font-size: 13px; color: #33414f; }
.cjb-card {
  background: #fff;
  border: 1px solid #dde7f0;
  border-radius: 10px;
  padding: 9px 11px;
  margin-top: 7px;
}
.cjb-cardt {
  display: block;
  font-weight: 700;
  font-size: 13.5px;
  color: #015b98;
  text-decoration: none;
  margin-bottom: 3px;
}
.cjb-cardt:hover { text-decoration: underline; }
.cjb-cardm { font-size: 12px; color: #5b6b7a; margin-bottom: 5px; }
.cjb-cardl { display: flex; flex-wrap: wrap; gap: 10px; }
.cjb-link { font-size: 12px; color: #0172be; text-decoration: none; }
.cjb-link:hover { text-decoration: underline; }

/* persistent choice menu (curated questions) above the input */
.cjb-menu {
  border-top: 1px solid #e4edf5;
  background: #fff;
  padding: 8px 10px 7px;
}
.cjb-menu[hidden] { display: none; }
.cjb-menuhead {
  font-size: 11.5px;
  font-weight: 700;
  color: #5b6b7a;
  margin-bottom: 6px;
}
.cjb-menurow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cjb-choice {
  border: 1px solid #b9d7ee;
  background: #fff;
  color: #015b98;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: start;
  line-height: 1.35;
}
.cjb-choice:hover { background: #eef6fc; }
.cjb-choice:focus-visible { outline: 2px solid #7fc4f2; outline-offset: 1px; }

.cjb-srclink {
  display: inline-block;
  margin-top: 7px;
  font-size: 12.5px;
  color: #015b98;
  text-decoration: none;
}
.cjb-srclink:hover { text-decoration: underline; }

.cjb-typing { gap: 4px; align-items: center; }
.cjb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9db4c6;
  display: inline-block;
  animation: cjb-blink 1.2s infinite both;
}
.cjb-typing span:nth-child(2) { animation-delay: 0.2s; }
.cjb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cjb-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.cjb-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e4edf5;
  background: #fff;
}
.cjb-input {
  flex: 1;
  border: 1px solid #cdd9e3;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
}
.cjb-input:focus { outline: 2px solid #7fc4f2; border-color: #0172be; }
.cjb-send {
  border: none;
  background: #0172be;
  color: #fff;
  width: 42px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cjb-send:hover { background: #015b98; }
.cjb-send:disabled { opacity: 0.55; cursor: default; }

@media (max-width: 480px) {
  .cjb-panel { right: 12px; left: 12px; width: auto; bottom: 88px; }
  .cjb-launcher { right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .cjb-panel, .cjb-launcher { transition: none; }
  .cjb-typing span { animation: none; }
}
