/* ---------- PageChatbot – minimal, themeable widget ---------- */
:root {
  --cbt-primary: #56ab2f;
  --cbt-bg: #ffffff;
  --cbt-text: #1a1a1a;
  --cbt-muted: #6b7280;
  --cbt-user: #0ea5e9;
  --cbt-border: #e8ebe5;
  --cbt-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  --cbt-radius: 14px;
  --cbt-z: 2147483000;

  /* Brand gradient + Firefox solid fallbacks for scrollbars */
  --primary-gradient: linear-gradient(135deg, #4b83ff, #56ab2f);
  --primary-scroll: #4b83ff; /* Firefox thumb color (solid only) */
  --primary-scroll-hover: #3b6fe0; /* Firefox hover (solid) */
}

@media (prefers-color-scheme: dark) {
  :root {
    --cbt-bg: #0a0f1a; /* deep navy background */
    --cbt-text: #e6f0ff; /* very light blue text */
    --cbt-muted: #7fa3cc; /* muted blue-green tone */
    --cbt-border: #56ab2f; /* dark greenish border */
    --cbt-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);

    /* Optional: Make gradient variables pop more in dark mode */
    --primary-gradient: linear-gradient(135deg, #4b83ff, #56ab2f);
    --primary-scroll: #4b83ff;
    --primary-scroll-hover: #56ab2f;
  }
}

/* Launcher button */
.pcbt-launcher {
  position: fixed;
  right: calc(
    var(--floating-button-right) + var(--floating-button-size) + var(--floating-button-gap)
  );
  bottom: var(--floating-button-bottom);
  width: var(--floating-button-size);
  height: var(--floating-button-size);
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  box-shadow: var(--floating-button-shadow);
  padding: 0;
  margin: 0;
  line-height: 1;
  cursor: pointer;
  z-index: var(--cbt-z);
  display: grid;
  place-items: center;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}
.pcbt-launcher:active {
  transform: scale(0.96);
}
.pcbt-launcher:hover {
  opacity: 0.9;
}
.pcbt-launcher svg {
  width: 20px;
  height: 20px;
}
.pcbt-launcher[aria-expanded='true'] {
  opacity: 0.85;
}

/* Match the back-to-top button's layer beneath the contact sidebar. */
body.open-sidebar .pcbt-launcher,
body.open-sidebar .pcbt-panel {
  z-index: 999;
}

/* Panel layout */
.pcbt-panel {
  position: fixed;
  right: 100px;
  bottom: 50px;
  width: min(380px, calc(100vw - 28px));
  height: 520px;
  background: var(--cbt-bg);
  color: var(--cbt-text);
  border: 1px solid var(--cbt-border);
  border-radius: var(--cbt-radius);
  box-shadow: var(--cbt-shadow);
  overflow: hidden; /* ensure only inner areas scroll */
  z-index: var(--cbt-z);
  display: none;
  flex-direction: column;
}
.pcbt-panel.open {
  display: flex;
}

/* Header */
.pcbt-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--cbt-border);
  background: linear-gradient(180deg, rgba(31, 124, 255, 0.08), transparent 60%);
}
.pcbt-title {
  font-weight: 700;
  font-size: 16px;
}
.pcbt-sub {
  font-size: 12px;
  color: var(--cbt-muted);
}
.pcbt-header .grow {
  flex: 1;
}
/* Replace loader with image logo */
.pcbt-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: block; /* image doesn't need grid centering */
  background: none; /* remove gradient background */
  overflow: hidden;
  background: url(../img/ps-logo.png) center/cover no-repeat !important;
  object-fit: cover; /* or contain if you want full visibility */
}

.pcbt-icon svg {
  display: none; /* hide default loader icon */
}

.pcbt-link {
  color: #4b83ff;
  text-decoration: underline;
}
.pcbt-link:hover {
  color: #3b6fe0;
}

.pcbt-close {
  border: none;
  background: var(--primary-gradient); /* same gradient as send */
  color: #fff; /* white icon */
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.pcbt-close:hover {
  opacity: 0.9; /* same hover effect as send button */
}

/* Clear button: same look as close/send */
.pcbt-clear,
.pcbt-close {
  border: none;
  background: var(--primary-gradient);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}
.pcbt-clear:hover,
.pcbt-close:hover {
  opacity: 0.9;
}

/* Suggestions area (horizontal scroll) */
.pcbt-suggest {
  order: 0;
  flex: 0 0 auto;
  padding: 6px 14px 8px;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;

  /* Firefox scrollbar (solid only) */
  scrollbar-width: thin;
  scrollbar-color: var(--primary-scroll) transparent;
}
/* WebKit scrollbar (gradient) */
.pcbt-suggest::-webkit-scrollbar {
  height: 6px;
}
.pcbt-suggest::-webkit-scrollbar-track {
  background: transparent;
}
.pcbt-suggest::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: var(--primary-gradient);
}
.pcbt-suggest::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--primary-scroll-hover), #4e9127);
}

.pcbt-chip {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--cbt-border);
  background: transparent;
  color: var(--cbt-text);
  cursor: pointer;
  white-space: nowrap;
}
.pcbt-chip:hover {
  border-color: var(--cbt-primary);
  color: var(--cbt-primary);
}

/* Messages area (dominant) */
.pcbt-body {
  order: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  cursor: default;

  /* Firefox scrollbar (solid only) */
  scrollbar-width: thin;
  scrollbar-color: var(--primary-scroll) transparent;
}
/* WebKit scrollbar (gradient) */
.pcbt-body::-webkit-scrollbar {
  width: 6px;
}
.pcbt-body::-webkit-scrollbar-track {
  background: transparent;
}
.pcbt-body::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: var(--primary-gradient);
}
.pcbt-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--primary-scroll-hover), #4e9127);
}

.pcbt-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.38;
  border: 1px solid var(--cbt-border);
  background: #fff;
  color: var(--cbt-text);
}
@media (prefers-color-scheme: dark) {
  .pcbt-msg {
    background: #0b1220;
  }
}
.pcbt-msg.user {
  margin-left: auto;
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.16), transparent 70%);
  border-color: rgba(14, 165, 233, 0.45);
}
.pcbt-msg.bot .src {
  display: block;
  font-size: 12px;
  color: var(--cbt-muted);
  margin-top: 6px;
}
.pcbt-msg.lowconf {
  border-style: dashed;
}

/* Input row */
.pcbt-input {
  order: 2;
  flex: 0 0 auto;
  border-top: 1px solid var(--cbt-border);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.pcbt-text {
  width: 100%;
  resize: none; /* prevent manual resize */
  height: 38px; /* one-line height */
  border: 1px solid var(--cbt-border);
  border-radius: 10px;
  padding: 8px 12px;
  line-height: 1.4;
  background: transparent;
  color: var(--cbt-text);
  overflow-y: hidden; /* no vertical scrollbar */
  transition: border 0.25s ease;
}

.pcbt-text:focus {
  outline: none; /* Remove default browser focus outline */
  border: 1px solid transparent; /* Needed for border-image to show */
  border-image: var(--primary-gradient) 1;
  border-radius: 10px; /* Keep your rounded edges */
}

.pcbt-send {
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--primary-gradient); /* brand gradient */
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.pcbt-send:hover {
  opacity: 0.9;
}
.pcbt-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Typing indicator */
.pcbt-typing {
  display: inline-block;
  width: 40px;
  aspect-ratio: 6 / 1;
  background: radial-gradient(circle closest-side, #9ca3af 90%, #0000) 0 / calc(100% / 3) 100%
    no-repeat;
  animation: cbtDots 1s infinite steps(3);
}
@keyframes cbtDots {
  to {
    background-position: 100% 0;
  }
}

/* Hints list */
.pcbt-hints {
  margin-top: 8px;
}
.pcbt-hints a {
  display: inline-block;
  margin: 6px 6px 0 0;
  font-size: 12px;
  color: var(--cbt-primary);
  text-decoration: none;
}
.pcbt-hints a:hover {
  text-decoration: underline;
}

/* Default desktop size */
.pcbt-panel {
  width: min(380px, calc(100vw - 28px));
  height: 520px;
}

/* Tablets (portrait/landscape) */
@media (max-width: 1024px) {
  .pcbt-panel {
    width: min(420px, calc(100vw - 24px));
    height: 60vh;
    bottom: 85px;
  }
}

/* Large mobile screens */
@media (max-width: 768px) {
  .pcbt-panel {
    width: calc(100vw - 24px);
    height: 65vh;
    right: 12px;
    left: 12px;
  }
  .pcbt-suggest {
    gap: 6px;
    padding: 4px 10px 6px;
  }
  .pcbt-chip {
    font-size: 11px;
    padding: 5px 8px;
  }
}

/* Small mobile screens */
@media (max-width: 460px) {
  .pcbt-panel {
    width: auto;
    height: 70vh;
    bottom: 80px;
    left: 10px;
    right: 10px;
    border-radius: 10px;
  }
  .pcbt-header {
    padding: 10px;
  }
  .pcbt-title {
    font-size: 14px;
  }
  .pcbt-sub {
    font-size: 11px;
  }
  .pcbt-chip {
    font-size: 10px;
    padding: 4px 7px;
  }
  .pcbt-text {
    font-size: 13px;
    padding: 6px 10px;
  }
  .pcbt-send {
    padding: 0 10px;
    font-size: 13px;
  }
}

/* Ultra-small screens */
@media (max-width: 340px) {
  .pcbt-panel {
    height: 75vh;
    left: 6px;
    right: 6px;
  }
  .pcbt-title {
    font-size: 13px;
  }
  .pcbt-sub {
    display: none; /* save space */
  }
}

/* Refined website assistant: consistent with the site's blue-green palette. */
.pcbt-panel {
  --cbt-bg: #f5f8fc;
  --cbt-text: #23344b;
  --cbt-muted: #65768b;
  --cbt-border: #dfe8f1;
  --cbt-primary: #287442;
  width: min(400px, calc(100vw - 32px));
  height: 570px;
  max-height: calc(100dvh - 112px);
  right: var(--floating-button-right, 24px);
  bottom: calc(var(--floating-button-bottom, 24px) + var(--floating-button-size, 40px) + 16px);
  border: 1px solid #c4d9d1;
  border-radius: 22px;
  background: var(--cbt-bg);
  color: var(--cbt-text);
  box-shadow:
    0 24px 70px rgba(14, 35, 61, 0.23),
    0 4px 14px rgba(14, 35, 61, 0.08);
  font-family: 'DM Sans', system-ui, sans-serif;
}
.pcbt-panel.open {
  animation: chatPanelIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.pcbt-panel .pcbt-header {
  flex: 0 0 auto;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 0;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(86, 171, 47, 0.2), transparent 70%),
    linear-gradient(115deg, #152b48, #143b45);
  color: #f5f8ff;
}
.pcbt-header .grow {
  min-width: 0;
}
.pcbt-panel .pcbt-icon {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 13px;
  background-color: #f0f7f5 !important;
  background-size: 30px !important;
  background-repeat: no-repeat !important;
}
.pcbt-panel .pcbt-title {
  margin-bottom: 4px;
  color: #f5f8ff;
  font-family: var(--heading-font, 'Space Grotesk', sans-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.pcbt-panel .pcbt-sub {
  display: block;
  color: #b5cfdf;
  font-size: 11px;
  line-height: 1.5;
}
.pcbt-panel .pcbt-close,
.pcbt-panel .pcbt-clear {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #e8f3fa;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}
.pcbt-panel .pcbt-close:hover,
.pcbt-panel .pcbt-clear:hover {
  opacity: 1;
  border-color: #8abd70;
  background: rgba(255, 255, 255, 0.16);
}
.pcbt-panel .pcbt-close svg,
.pcbt-panel .pcbt-clear svg {
  width: 17px;
  height: 17px;
}
.pcbt-panel .pcbt-suggest {
  flex-wrap: wrap;
  gap: 7px;
  max-height: 116px;
  padding: 14px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  border-bottom: 1px solid #e4ebf3;
  background: #fff;
  scrollbar-color: #b8ccda transparent;
}
.pcbt-panel .pcbt-chip {
  max-width: 100%;
  padding: 8px 11px;
  border: 1px solid #dce7ec;
  border-radius: 10px;
  background: #f5f9fb;
  color: #43566e;
  font:
    500 11px/1.5 'DM Sans',
    system-ui,
    sans-serif;
  white-space: normal;
  text-align: left;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease;
}
.pcbt-panel .pcbt-chip:hover {
  color: #23634e;
  border-color: #9dc68e;
  background: #eef7eb;
}
.pcbt-panel .pcbt-body {
  gap: 14px;
  padding: 20px 16px;
  background:
    radial-gradient(ellipse at 100% 100%, rgba(86, 171, 47, 0.035), transparent 65%), #f5f8fc;
  scrollbar-color: #b8ccda transparent;
}
.pcbt-panel .pcbt-body::-webkit-scrollbar-thumb,
.pcbt-panel .pcbt-suggest::-webkit-scrollbar-thumb {
  background: #b8ccda;
}
.pcbt-panel .pcbt-msg {
  max-width: 90%;
  padding: 13px 15px;
  border: 1px solid #e1e9f1;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  color: #304259;
  font-size: 14px;
  line-height: 1.7;
  box-shadow: 0 3px 8px rgba(20, 43, 72, 0.025);
  overflow-wrap: anywhere;
  animation: chatMessageIn 0.22s ease both;
}
.pcbt-panel .pcbt-msg.user {
  border-color: transparent;
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(120deg, #235dcc, #236a9e 55%, #287641);
  color: #fff;
}
.pcbt-panel .pcbt-msg.user a {
  color: #fff;
}
.pcbt-panel .pcbt-msg.bot .src {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #edf1f5;
  color: #738399;
  font-size: 11px;
}
.pcbt-panel .pcbt-link {
  color: #2863b5;
  text-underline-offset: 3px;
}
.pcbt-panel .pcbt-input {
  align-items: end;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid #e1e9f1;
  background: #fff;
}
.pcbt-panel .pcbt-text {
  min-width: 0;
  min-height: 44px;
  height: 44px;
  padding: 11px 13px;
  border: 1px solid #d8e3ee;
  border-radius: 13px;
  background: #f7f9fc;
  color: #23344b;
  font:
    400 14px/1.5 'DM Sans',
    system-ui,
    sans-serif;
  overflow-y: auto;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.pcbt-panel .pcbt-text::placeholder {
  color: #7d8da0;
}
.pcbt-panel .pcbt-text:focus {
  border: 1px solid #7babe2;
  border-image: none;
  border-radius: 13px;
  box-shadow: 0 0 0 3px rgba(75, 131, 255, 0.1);
  outline: none;
}
.pcbt-panel .pcbt-send {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 13px;
  background: linear-gradient(120deg, #235dcc, #287641);
  color: #fff;
  font:
    600 13px 'DM Sans',
    system-ui,
    sans-serif;
}
.pcbt-panel button:focus-visible {
  outline: 3px solid #86aff0;
  outline-offset: 2px;
}
.pcbt-panel button,
.pcbt-panel a {
  cursor: pointer !important;
}
.pcbt-panel .pcbt-text {
  cursor: text !important;
  overflow-y: hidden;
  scrollbar-width: none;
}
.pcbt-panel .pcbt-text::-webkit-scrollbar {
  display: none;
}
.pcbt-panel .pcbt-typing {
  background-image: radial-gradient(circle closest-side, #638fbd 90%, #0000);
}
@keyframes chatPanelIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes chatMessageIn {
  from {
    opacity: 0;
    translate: 0 5px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@media (max-width: 768px) {
  .pcbt-panel,
  .pcbt-panel.open {
    left: 12px;
    right: 12px;
    width: auto;
    height: min(570px, calc(100dvh - 112px));
    bottom: calc(var(--floating-button-bottom, 24px) + var(--floating-button-size, 44px) + 12px);
    border-radius: 20px;
  }
}
@media (max-width: 359px) {
  .pcbt-panel .pcbt-header {
    gap: 8px;
    padding: 16px 12px;
  }
  .pcbt-panel .pcbt-title {
    font-size: 15px;
  }
  .pcbt-panel .pcbt-icon {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }
  .pcbt-panel .pcbt-input {
    gap: 8px;
    padding: 12px;
  }
  .pcbt-panel .pcbt-send {
    padding: 0 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .pcbt-panel.open,
  .pcbt-panel .pcbt-msg,
  .pcbt-panel .pcbt-typing {
    animation: none;
  }
  .pcbt-panel .pcbt-body {
    scroll-behavior: auto;
  }
  .pcbt-panel button,
  .pcbt-panel .pcbt-text {
    transition: none;
  }
}

@media (max-width: 767px) {
  .pcbt-panel .pcbt-text {
    font-size: 16px;
  }
  .pcbt-panel .pcbt-close,
  .pcbt-panel .pcbt-clear {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }
}
@media (max-width: 767px) and (max-height: 520px) {
  .pcbt-panel.open {
    top: 8px;
    bottom: 8px;
    height: auto;
    max-height: none;
  }
  .pcbt-panel .pcbt-header {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .pcbt-panel .pcbt-suggest {
    max-height: 64px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}
