/* Simple Chatbot widget styles.
   Layout/spacing/interaction pattern follows the "Ask Codaires AI" design
   file (transcript-style Q&A, no chat bubbles, suggested-prompts list,
   underline input). Self-contained hex values (not CSS vars) since this
   plugin runs standalone on its own WordPress install, with no knowledge of
   codaires-site's tokens.css. */
:root {
  --sc-color: #9e4f35;
  --sc-color-dark: #7d3e2a;
  --sc-radius: 16px;
  --sc-control-radius: 8px;
  --sc-shadow: 0 16px 48px rgba(17, 12, 8, 0.22);
  --sc-z: 99999;
}

#simple-chatbot-root * {
  box-sizing: border-box;
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Toggle button */
#simple-chatbot-toggle {
  position: fixed;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--sc-color);
  color: #f9f5ec;
  border: none;
  cursor: pointer;
  box-shadow: var(--sc-shadow);
  z-index: var(--sc-z);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s, opacity 0.15s;
}
#simple-chatbot-toggle:hover,
#simple-chatbot-toggle:focus {
  background: var(--sc-color-dark);
  transform: scale(1.07);
  outline: 3px solid rgba(158, 79, 53, 0.35);
}
#simple-chatbot-toggle svg {
  width: 26px;
  height: 26px;
  fill: #f9f5ec;
  pointer-events: none;
}
/* Hide the FAB while the panel is open — the header's own close button
   already covers that, so a second circle floating behind the panel is
   redundant. */
#simple-chatbot-root.sc-open #simple-chatbot-toggle {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

/* Position variants */
.sc-pos-bottom-right #simple-chatbot-toggle { bottom: 24px; right: 24px; }
.sc-pos-bottom-left  #simple-chatbot-toggle { bottom: 24px; left:  24px; }
.sc-pos-bottom-right #simple-chatbot-panel  { bottom: 92px; right: 24px; }
.sc-pos-bottom-left  #simple-chatbot-panel  { bottom: 92px; left:  24px; }

/* Panel — animated open/close driven by the .sc-panel-open class (see
   widget.js openPanel/closePanel). [hidden] still fully removes it from
   layout/the a11y tree once the closing transition finishes. */
#simple-chatbot-panel {
  position: fixed;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #fffdf8;
  border: 1px solid rgba(17, 12, 8, 0.14);
  border-radius: var(--sc-radius);
  box-shadow: var(--sc-shadow);
  z-index: var(--sc-z);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: scale(0.94) translateY(14px);
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
#simple-chatbot-panel.sc-panel-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}
#simple-chatbot-panel[hidden] {
  display: none;
}
.sc-pos-bottom-left #simple-chatbot-panel {
  transform-origin: bottom left;
}

/* Header */
#simple-chatbot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(17, 12, 8, 0.14);
}
.sc-eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sc-color);
}
.sc-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-top: 2px;
  color: #110c08;
}
.sc-close-btn {
  background: none;
  border: none;
  color: rgba(17, 12, 8, 0.55);
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
}
.sc-close-btn:hover { background: rgba(17, 12, 8, 0.08); color: #110c08; }
.sc-close-btn svg { width: 17px; height: 17px; pointer-events: none; }

/* Transcript */
#simple-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

.sc-intro {
  border-left: 1px solid var(--sc-color);
  padding-left: 14px;
  margin-bottom: 28px;
}
.sc-intro-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(17, 12, 8, 0.55);
  margin-bottom: 9px;
}
.sc-intro-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.62;
  color: #110c08;
}

.sc-turn { margin-bottom: 28px; }
.sc-turn-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(17, 12, 8, 0.55);
  margin-bottom: 9px;
}
.sc-turn-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.62;
  color: #110c08;
  text-align: justify;
  hyphens: auto;
}
.sc-turn-error .sc-turn-text { color: #a02525; text-align: left; }
.sc-turn-sources {
  font-size: 12px;
  margin-top: 8px;
  color: rgba(17, 12, 8, 0.55);
}
.sc-turn-sources a {
  color: var(--sc-color);
  text-decoration: underline;
}

/* Typing indicator */
.sc-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 28px;
}
.sc-typing span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--sc-color);
  animation: sc-blip 1.2s infinite;
}
.sc-typing span:nth-child(2) { animation-delay: 0.2s; }
.sc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sc-blip {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 1; }
}

/* Suggested prompts */
.sc-prompts-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(17, 12, 8, 0.55);
  margin-bottom: 14px;
}
#simple-chatbot-prompts-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(17, 12, 8, 0.14);
}
.sc-prompt-row {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(17, 12, 8, 0.14);
  text-align: left;
  cursor: pointer;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14px;
  color: #110c08;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
}
.sc-prompt-row:hover { color: var(--sc-color); }
.sc-prompt-row svg { width: 14px; height: 14px; flex-shrink: 0; stroke: var(--sc-color); }

/* Footer / input area */
#simple-chatbot-input-area {
  border-top: 1px solid rgba(17, 12, 8, 0.14);
  padding: 14px 18px 18px;
  background: #fffdf8;
}
.sc-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.sc-footer-row:empty { display: none; }
.sc-footer-row:not(:empty) { padding-bottom: 14px; }
.sc-footer-label {
  font-size: 12px;
  color: rgba(17, 12, 8, 0.55);
  font-style: italic;
}
.sc-footer-link,
.sc-footer-row > button.sc-footer-link {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 14px;
  color: #110c08;
  text-decoration: none;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-bottom: 1px solid var(--sc-color);
  padding-bottom: 1px;
}

.sc-input-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  border-top: 1px solid rgba(17, 12, 8, 0.14);
  padding-top: 14px;
}
#simple-chatbot-input-area:has(.sc-footer-row:empty) .sc-input-row {
  border-top: none;
  padding-top: 0;
}
#simple-chatbot-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(17, 12, 8, 0.25);
  border-radius: 0;
  padding: 6px 0;
  font-size: 14px;
  resize: none;
  min-height: 32px;
  max-height: 120px;
  outline: none;
  line-height: 1.4;
  color: #110c08;
  transition: border-color 0.15s;
  font-family: inherit;
}
#simple-chatbot-input:focus {
  border-bottom-color: var(--sc-color);
}
#simple-chatbot-send {
  appearance: none;
  background: transparent;
  border: 1px solid var(--sc-color);
  border-radius: var(--sc-control-radius);
  color: var(--sc-color);
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
#simple-chatbot-send:hover { background: rgba(158, 79, 53, 0.12); }
#simple-chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }
#simple-chatbot-send svg { width: 16px; height: 16px; pointer-events: none; }

/* Accessibility: screen-reader only */
.sc-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 440px) {
  #simple-chatbot-panel { width: calc(100vw - 20px); }
  .sc-pos-bottom-right #simple-chatbot-panel { right: 10px; }
  .sc-pos-bottom-left  #simple-chatbot-panel { left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  #simple-chatbot-panel {
    transition: opacity 0.01s linear;
    transform: none;
  }
  #simple-chatbot-panel.sc-panel-open {
    transform: none;
  }
}

/* Rich-text bot answers */
.sc-msg-body p { margin: 0 0 8px; }
.sc-msg-body p:last-child { margin-bottom: 0; }
.sc-msg-body ul,
.sc-msg-body ol { margin: 4px 0 8px; padding-left: 20px; }
.sc-msg-body li { margin: 2px 0; }
.sc-msg-body strong { font-weight: 600; }
.sc-msg-body a { color: var(--sc-color); text-decoration: underline; }

/* Lead form (ctaMode: 'form') */
.sc-lead-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sc-lead-intro { margin: 0; font-size: 13px; color: rgba(17, 12, 8, 0.62); }
.sc-lead-input {
  border: none;
  border-bottom: 1px solid rgba(17, 12, 8, 0.25);
  border-radius: 0;
  padding: 6px 0;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  resize: none;
  background: transparent;
  color: #110c08;
}
.sc-lead-input:focus { outline: none; border-bottom-color: var(--sc-color); }
.sc-cta-send {
  align-self: flex-start;
  appearance: none;
  background: var(--sc-color);
  color: #f9f5ec;
  border: none;
  border-radius: var(--sc-control-radius);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.sc-cta-send:hover { background: var(--sc-color-dark); }
.sc-cta-send:disabled { opacity: 0.6; cursor: default; }
.sc-lead-status { font-size: 12px; color: rgba(17, 12, 8, 0.62); min-height: 1em; }
.sc-lead-status.sc-lead-error { color: #a02525; }
.sc-lead-thanks {
  padding: 10px 0;
  color: #3e5a44;
  font-size: 14px;
}
/* Honeypot — visually hidden, off-screen, not display:none (bots skip those) */
.sc-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  opacity: 0;
}
