/* =========================================================
   SeedChat Widget — floating button + embed
   Primary color is controlled via --sc-primary CSS variable.
   Default: #1a73e8. Override via Settings → Primary Color.
   ========================================================= */

.sc-hidden { display: none !important; }

/* ----- Floating action button ----- */
.sc-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sc-primary, #1a73e8);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s, filter .2s;
}
.sc-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,.32);
  filter: brightness(0.9);
}

/* ----- Floating panel ----- */
.sc-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 360px;
  height: 500px;
  z-index: 99998;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  background: #fff;
  transform-origin: bottom right;
  animation: sc-pop .2s ease;
  /* Smoothly re-anchor when toggled to/from the docked sidebar (T6). */
  transition: right .3s ease, bottom .3s ease, top .3s ease,
              width .3s ease, height .3s ease, border-radius .3s ease;
}
@keyframes sc-pop {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0);    }
}

/* CookieConsent's bottom banner occupies the same corner as the floating chat.
   Keep the FAB and panel above it while the banner is visible. */
body > .cc-window.cc-bottom:not(.cc-invisible) ~ .sc-fab {
  bottom: calc(24px + 84px);
}
body > .cc-window.cc-bottom:not(.cc-invisible) ~ .sc-panel {
  bottom: calc(92px + 84px);
  height: min(500px, calc(100dvh - 200px));
}

/* ── Expand → docked right sidebar (T6) ────────────────────────────
   The "expand" button re-anchors the same floating panel to the right
   edge, full height, so the article stays readable beside it. Only the
   geometry changes — the panel's own design (header, colours, layout)
   is untouched. The second selector simply out-specifies the
   CookieConsent override above so docking wins while the banner shows. */
.sc-panel.sc-panel--docked,
body > .cc-window.cc-bottom:not(.cc-invisible) ~ .sc-panel.sc-panel--docked {
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  box-shadow: -10px 0 44px rgba(0, 0, 0, .14);
}
/* Push the page content left so the sidebar never covers it. Some templates
   pin <body> to the viewport width, so margin-right alone leaves full-width
   content under the panel — constrain the width too (needs !important to beat
   the theme's own width rule) so the page genuinely reflows into the space
   left of the sidebar. */
html.sc-chat-docked body {
  width: calc(100% - 420px) !important;
  max-width: calc(100% - 420px) !important;
  margin-right: 420px;
  transition: width .3s ease, margin-right .3s ease;
}
/* The floating button is redundant while the sidebar is open. */
html.sc-chat-docked .sc-fab { display: none; }
/* Flip the expand glyph to hint the click now collapses back. */
.sc-panel--docked .sc-expand svg { transform: rotate(180deg); }

@media (max-width: 600px) {
  /* On phones the sidebar takes the full screen; no content offset. */
  .sc-panel.sc-panel--docked,
  body > .cc-window.cc-bottom:not(.cc-invisible) ~ .sc-panel.sc-panel--docked {
    width: 100%;
  }
  html.sc-chat-docked body {
    width: auto !important;
    max-width: none !important;
    margin-right: 0;
  }
  /* The panel already fills a phone screen, so "expand" has nothing to do —
     hide it. And stop the FAB (higher z-index) from overlapping the open
     panel's input field. */
  .sc-panel .sc-expand { display: none; }
  .sc-panel:not(.sc-hidden) ~ .sc-fab { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html.sc-chat-docked body { transition: none; }
}

/* ----- Embed (shortcode) ----- */
.sc-embed {
  width: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  min-height: 400px;
}

/* ----- Header ----- */
.sc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--sc-primary, #1a73e8);
  color: #fff;
  flex-shrink: 0;
}
.sc-title {
  font-size: 15px;
  font-weight: 600;
  font-family: "Thongterm", sans-serif;
  letter-spacing: -.01em;
}
.sc-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.sc-close,
.sc-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.sc-close svg,
.sc-expand svg {
  display: block;
}
.sc-close:hover,
.sc-expand:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
}

/* ----- Messages area ----- */
.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  scroll-behavior: smooth;
  border-radius: 20px 20px 0 0;
}
.sc-messages::-webkit-scrollbar { width: 4px; }
.sc-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* ----- Bubbles ----- */
.sc-msg {
  display: flex;
  max-width: 85%;
}
.sc-msg--user { align-self: flex-end; }
.sc-msg--bot  { align-self: flex-start; }

.sc-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  font-family: "Thongterm", sans-serif;
  word-break: break-word;
}
.sc-msg--user .sc-bubble {
  background: var(--sc-primary, #1a73e8);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sc-msg--bot .sc-bubble {
  background: #fff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.sc-msg--error .sc-bubble {
  background: #fef2f2;
  color: #dc2626;
}

/* ----- Markdown inside bot bubbles ----- */
.sc-msg--bot .sc-bubble ol,
.sc-msg--bot .sc-bubble ul {
  margin: 4px 0;
  padding-left: 20px;
}
.sc-msg--bot .sc-bubble li { margin-bottom: 6px; }
.sc-msg--bot .sc-bubble strong { font-weight: 600; }
.sc-msg--bot .sc-bubble em { font-style: italic; }
.sc-msg--bot .sc-bubble a {
  color: var(--sc-primary, #1a73e8);
  text-decoration: underline;
  word-break: break-all;
}

/* ----- Typing indicator ----- */
.sc-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 3px 0;
}
.sc-typing span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: sc-bounce 1.2s infinite;
}
.sc-typing span:nth-child(2) { animation-delay: .2s; }
.sc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes sc-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-5px); }
}

/* ----- Input bar ----- */
.sc-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.sc-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 14px;
  font-family: "Thongterm", sans-serif;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  background: #f8fafc;
  transition: border-color .15s, background .15s;
  color: #1e293b;
}
.sc-input:focus {
  border-color: var(--sc-primary, #1a73e8);
  background: #fff;
}
.sc-input::placeholder { color: #94a3b8; }

.sc-send--ask{
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: #111f39;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, filter .15s, transform .1s;
}
.sc-send--ask:hover:not(:disabled) { filter: brightness(0.85); }
.sc-send--ask:active:not(:disabled) { transform: scale(.93); }
.sc-send--ask:disabled { background: #ebebeb; cursor: not-allowed; }

.sc-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--sc-primary, #1a73e8);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter .15s, transform .1s;
}
.sc-send:hover:not(:disabled) { filter: brightness(0.85); }
.sc-send:active:not(:disabled) { transform: scale(.93); }
.sc-send:disabled { background: #cbd5e1; cursor: not-allowed; }

/* ----- Page-embed block [seedchat_page] shortcode ----- */
.sc-page-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(800px, calc(100% - 32px));
  height: 580px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,.22);
}
@media (max-width: 480px) {
  .sc-page-overlay {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }
}

/* ----- Page Template block ----- */
.seedchat-tpl-wrap {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 16px;
}
.seedchat-tpl-block {
  height: 680px;
  min-height: 500px;
}
.seedchat-tpl-notice {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
  font-family: "Thongterm", sans-serif;
}

/* =========================================================
   Ask AI — single-post article mode
   (FAB pill + dark header + intro + suggestion chips)
   ========================================================= */

.sc-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.sc-spark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

/* Dark header to match the Ask AI design */
.sc-header--ask {
  background: #111F39;
}
.sc-header--ask .sc-title {
  font-family: sansfrancais, sans-serif;
  font-weight: 400;
  font-size: 14px;
}

/* FAB becomes a labelled pill */
.sc-fab--ask {
  width: auto;
  height: auto;
  border-radius: 24px;
  padding: 10px 16px;
  gap: 6px;
  background: #111F39;
  font-family: sansfrancais, sans-serif;
}
.sc-fab--ask:hover {
  filter: brightness(1.2);
}
.sc-fab--ask .sc-fab-text {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -.01em;
  white-space: nowrap;
}

/* General float button = brand logo badge (navy circle).
   The logo SVG fills the whole button; on open the × shows on the same navy. */
.sc-fab--logo {
  background: #111F39;
  padding: 0;
}
.sc-fab--logo .sc-fab-icon--chat {
  width: 56px;
  height: 56px;
}

/* Panel itself stays white — only the header is navy (the sc-header--ask
   class also lives on the panel, so neutralise its dark background here). */
.sc-panel--ask {
  background: #fff;
}

/* Tuck the white content up under the navy header so the rounded top
   corners of the messages area reveal the navy behind them (design spec). */
.sc-panel--ask .sc-header {
  padding-bottom: 28px;
}
.sc-panel--ask .sc-messages {
  position: relative;
  margin-top: -20px;
}

/* Ask AI input — gradient pill border matching the /chat page */
.sc-panel--ask .sc-input-wrap {
  align-items: center;
  gap: 8px;
  margin: 4px 14px 14px;
  padding: 8px 8px 8px 20px;
  border: 1px solid transparent;
  border-radius: 100px;
  background-image: linear-gradient(#fff, #fff),
                    linear-gradient(90.51deg, #8bace9 0.41%, #111f39 58.19%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 0 0 4px rgba(139,172,233,.12), 0 4px 16px 0 rgba(166,197,254,.25);
  transition: box-shadow .2s;
}
.sc-panel--ask .sc-input-wrap:focus-within {
  box-shadow: 0 0 0 4px rgba(139,172,233,.22), 0 4px 20px 0 rgba(166,197,254,.4);
}
.sc-panel--ask .sc-input,
.sc-panel--ask .sc-input:focus {
  border: none;
  background: transparent;
  padding: 0;
  height: 19px;
  min-height: 19px;
  line-height: 19px;
  overflow-y: hidden;
  font-family: "Sukhumvit Tadmai", sans-serif;
}
.sc-panel--ask .sc-input::placeholder {
  font-family: "Sukhumvit Tadmai", sans-serif;
}

/* Intro block shown at the top of an article chat */
.sc-intro {
  padding: 4px 4px 2px;
  font-family: "Thongterm", sans-serif;
}
.sc-intro-title {
  font-size: 16px;
  font-weight: 700;
  color: #333333;
  margin-bottom: 6px;
}
.sc-intro-sub {
  font-size: 13.5px;
  color: #333333;
  line-height: 1.5;
}
.sc-intro-hint {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  font-size: 13.5px;
  color: #333333;
}

/* Suggestion chips — stacked, right-aligned */
.sc-suggest {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.sc-chip {
  background: #fff;
  border: 1px solid #d9e1ec;
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 13.5px;
  line-height: 1.4;
  color: #1e293b;
  cursor: pointer;
  text-align: right;
  max-width: 92%;
  font-family: "Thongterm", sans-serif;
  transition: border-color .15s, background .15s, color .15s;
}
.sc-chip:hover {
  border-color: var(--sc-primary, #1a73e8);
  color: var(--sc-primary, #1a73e8);
  background: #f8faff;
}

/* ----- Mobile ----- */
@media (max-width: 480px) {
  .sc-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }
  .sc-fab {
    bottom: 16px;
    right: 16px;
  }
  .sc-fab--ask {
    padding: 11px 16px;
  }
  body > .cc-window.cc-bottom:not(.cc-invisible) ~ .sc-fab {
    bottom: calc(16px + 120px);
  }
  body > .cc-window.cc-bottom:not(.cc-invisible) ~ .sc-panel {
    bottom: 0;
    height: 100dvh;
  }
}
