/**
 * widget.css
 */

.site-walker-wp {
  position: fixed;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.site-walker-wp[hidden] {
  display: none;
}

.site-walker-wp.swwp-pos-bottom-right {
  right: var(--swwp-offset-x);
  bottom: var(--swwp-offset-y);
}

.site-walker-wp.swwp-pos-bottom-left {
  left: var(--swwp-offset-x);
  bottom: var(--swwp-offset-y);
}

.site-walker-wp.swwp-pos-top-right {
  right: var(--swwp-offset-x);
  top: var(--swwp-offset-y);
}

.site-walker-wp.swwp-pos-top-left {
  left: var(--swwp-offset-x);
  top: var(--swwp-offset-y);
}

.swwp-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--swwp-button-bg);
  color: var(--swwp-button-fg);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s ease;
}

.swwp-launcher:hover,
.swwp-launcher:focus {
  transform: scale(1.05);
}

.swwp-launcher svg {
  width: 26px;
  height: 26px;
}

.swwp-panel {
  position: absolute;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 48px);
  background: #fff;
  color: #1f2937;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.swwp-panel[hidden] {
  display: none;
}

.site-walker-wp.swwp-pos-bottom-right .swwp-panel {
  right: 0;
  bottom: 70px;
}

.site-walker-wp.swwp-pos-bottom-left .swwp-panel {
  left: 0;
  bottom: 70px;
}

.site-walker-wp.swwp-pos-top-right .swwp-panel {
  right: 0;
  top: 70px;
}

.site-walker-wp.swwp-pos-top-left .swwp-panel {
  left: 0;
  top: 70px;
}

.swwp-panel-header {
  background: var(--swwp-accent);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.swwp-panel-title {
  font-weight: 600;
  font-size: 15px;
}

.swwp-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.swwp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f9fafb;
}

.swwp-message {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.4;
  font-size: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.swwp-message-user {
  align-self: flex-end;
  background: var(--swwp-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.swwp-message-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.swwp-message-assistant a {
  color: var(--swwp-accent);
  text-decoration: underline;
  word-break: break-all;
}

.swwp-message-assistant strong {
  font-weight: 600;
}

.swwp-message-assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 4px;
}

.swwp-message-assistant h3 {
  font-size: 1em;
  font-weight: 600;
  margin: 6px 0 2px;
}

.swwp-message-assistant h3:first-child {
  margin-top: 0;
}

.swwp-message-assistant ul,
.swwp-message-assistant ol {
  margin: 4px 0;
  padding-left: 1.5em;
}

.swwp-message-assistant li {
  margin: 2px 0;
}

.swwp-message-assistant em {
  font-style: italic;
}

.swwp-message-system {
  align-self: center;
  background: transparent;
  color: #6b7280;
  font-size: 12px;
  font-style: italic;
}

.swwp-message.swwp-pending {
  opacity: 0.6;
}

.swwp-input-row,
.swwp-email-row {
  display: flex;
  /* align-items: flex-end; */
  align-items: stretch;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

/*
.swwp-input-row .swwp-send {
  height: 40px;
}
*/

.swwp-input {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  max-height: 120px;
  outline: none;
}

.swwp-input:focus {
  border-color: var(--swwp-accent);
}

.swwp-send {
  background: var(--swwp-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 16px;
}

.swwp-send:hover,
.swwp-send:focus {
  filter: brightness(1.1);
}

.swwp-input:disabled,
.swwp-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

/* Hard-handoff email capture — replaces the input row when
   session_terminated fires. Styled to feel like a natural
   continuation of the input idiom. */
.swwp-email-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.swwp-email-input:focus {
  border-color: var(--swwp-accent);
}

.swwp-email-send {
  background: var(--swwp-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 16px;
}

.swwp-email-send:hover,
.swwp-email-send:focus {
  filter: brightness(1.1);
}

.swwp-email-input:disabled,
.swwp-email-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

/* Voluntary "Request an email back" CTA — small, low-key link above
   the input row. Hidden by JS when entering the email flow or when the
   session terminates. */
.swwp-email-cta {
  padding: 6px 10px;
  text-align: center;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.swwp-email-cta-link {
  font-size: 12px;
  color: #50575e;
  text-decoration: underline;
}

.swwp-email-cta-link:hover,
.swwp-email-cta-link:focus {
  color: var(--swwp-accent);
}

/* Inline success / error message above the email form. JS toggles
   `.is-success` / `.is-error` for colour cues. */
.swwp-email-message {
  padding: 10px 14px;
  font-size: 13px;
  text-align: center;
  border-top: 1px solid #e5e7eb;
}

.swwp-email-message.is-success {
  background: #f0fdf4;
  color: #166534;
}

.swwp-email-message.is-error {
  background: #fef2f2;
  color: #991b1b;
}

/* Back-to-chat link — shown only when the chat is not terminated. */
.swwp-email-back {
  padding: 6px 10px;
  text-align: center;
  background: #fff;
}

.swwp-email-back-link {
  font-size: 12px;
  color: #50575e;
  text-decoration: underline;
}

.swwp-email-back-link:hover,
.swwp-email-back-link:focus {
  color: var(--swwp-accent);
}
