/* ---------- 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,.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,.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: 100px;
  bottom: 26px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cbt-primary), #4b83ff);
  color: #fff;
  border: none;
  box-shadow: var(--cbt-shadow);
  cursor: pointer;
  z-index: var(--cbt-z);
  display: grid;
  place-items: center;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
}
.pcbt-launcher:active { transform: scale(.96); }
.pcbt-launcher svg { width: 26px; height: 26px; }
.pcbt-launcher[aria-expanded="true"] { opacity: .85; }

/* 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,.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 .2s ease;
}
.pcbt-clear:hover,
.pcbt-close:hover { opacity: .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,.16), transparent 70%);
  border-color: rgba(14,165,233,.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 */
  }
}

