/* ─────────────────────────────────────────────────────────────────────────────
   Shepherd Digital Chat Agent — Styles
   ───────────────────────────────────────────────────────────────────────────── */

/* Variables */
:root {
  --sdca-navy:        #1F3D6B;
  --sdca-blue:        #2E75B6;
  --sdca-teal:        #007A87;
  --sdca-teal-light:  #D0EDF0;
  --sdca-white:       #FFFFFF;
  --sdca-bg:          #F4F6FA;
  --sdca-border:      #E0E8F0;
  --sdca-text:        #2D2D2D;
  --sdca-muted:       #777;
  --sdca-radius:      14px;
  --sdca-shadow:      0 8px 32px rgba(31, 61, 107, 0.18);
  --sdca-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;

  /* Chip-specific variables (overridable via admin) */
  --sdca-chip-bg:       #FFFFFF;
  --sdca-chip-text:     #2D2D2D;
  --sdca-chip-border:   #E0E8F0;
  --sdca-chip-hover-bg: #D0EDF0;
}

/* ── Toggle Button ───────────────────────────────────────────────────────── */
#sdca-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: var(--sdca-font);
}

#sdca-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--sdca-navy);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(31, 61, 107, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  color: #fff;
  outline: none;
  margin-left: auto;
}

#sdca-toggle:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 20px rgba(31, 61, 107, 0.45);
}

#sdca-toggle:focus-visible {
  outline: 3px solid var(--sdca-teal);
  outline-offset: 3px;
}

/* ── Chat Window ─────────────────────────────────────────────────────────── */
#sdca-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-height: 520px;
  background: var(--sdca-white);
  border-radius: var(--sdca-radius);
  box-shadow: var(--sdca-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.92) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.18s ease;
}

#sdca-window.sdca-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#sdca-header {
  background: var(--sdca-navy);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#sdca-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sdca-teal);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#sdca-header-info {
  flex: 1;
  min-width: 0;
}

#sdca-agent-name {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

#sdca-agent-status {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sdca-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  display: inline-block;
  animation: sdca-pulse 2s ease-in-out infinite;
}

@keyframes sdca-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#sdca-header-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}
#sdca-header-close:hover { color: #fff; }

/* ── Messages area ───────────────────────────────────────────────────────── */
#sdca-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#sdca-messages::-webkit-scrollbar { width: 4px; }
#sdca-messages::-webkit-scrollbar-track { background: transparent; }
#sdca-messages::-webkit-scrollbar-thumb { background: var(--sdca-border); border-radius: 4px; }

/* Bubbles */
.sdca-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  animation: sdca-fade-in 0.2s ease;
}

@keyframes sdca-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sdca-msg-agent {
  align-self: flex-start;
}

.sdca-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.sdca-msg-mini-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sdca-teal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.sdca-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--sdca-text);
  word-break: break-word;
}

.sdca-msg-agent .sdca-bubble {
  background: var(--sdca-bg);
  border-bottom-left-radius: 4px;
  color: var(--sdca-text);
}

.sdca-msg-user .sdca-bubble {
  background: var(--sdca-navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */
#sdca-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px 10px;
  flex-shrink: 0;
}

.sdca-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sdca-teal);
  animation: sdca-bounce 1.2s ease-in-out infinite;
}
.sdca-dot:nth-child(2) { animation-delay: 0.2s; }
.sdca-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes sdca-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Input row ───────────────────────────────────────────────────────────── */
#sdca-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--sdca-border);
  background: var(--sdca-white);
  flex-shrink: 0;
}

#sdca-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--sdca-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: var(--sdca-font);
  color: var(--sdca-text);
  background: var(--sdca-bg);
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.5;
}

#sdca-input:focus {
  border-color: var(--sdca-blue);
  background: #fff;
}

#sdca-input::placeholder { color: #aab; }

#sdca-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sdca-navy);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  transition: background 0.15s, transform 0.15s;
  outline: none;
}

#sdca-send:hover:not(:disabled) {
  background: var(--sdca-teal);
  transform: scale(1.05);
}

#sdca-send:disabled {
  background: #c0cad8;
  cursor: not-allowed;
}

#sdca-send:focus-visible {
  outline: 3px solid var(--sdca-teal);
  outline-offset: 2px;
}

/* ── Footer note ─────────────────────────────────────────────────────────── */
#sdca-footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--sdca-muted);
  padding: 5px 12px 9px;
  border-top: 1px solid var(--sdca-border);
  flex-shrink: 0;
}

#sdca-footer-note a {
  color: var(--sdca-muted);
  text-decoration: underline;
}

/* Lead captured banner */
.sdca-lead-banner {
  background: linear-gradient(135deg, var(--sdca-teal-light), #e8f8fb);
  border: 1px solid var(--sdca-teal);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--sdca-teal);
  font-weight: 600;
  text-align: center;
  animation: sdca-fade-in 0.3s ease;
}

/* ─────────────────────────────────────────────────────────────────────────────
   INLINE CHAT  [sdca_inline]
   ───────────────────────────────────────────────────────────────────────────── */

.sdca-inline-wrap {
  font-family: var(--sdca-font);
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

/* ── Pre-engagement (idle) state ─────────────────────────────────────────── */
.sdca-inline-idle {
  text-align: center;
  padding: 8px 0 4px;
  transition: opacity 0.25s ease, max-height 0.3s ease;
  overflow: hidden;
}

.sdca-inline-idle.sdca-hiding {
  opacity: 0;
  max-height: 0 !important;
  pointer-events: none;
}

.sdca-inline-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sdca-teal);
  margin: 0 0 8px;
}

.sdca-inline-headline {
  font-size: 22px;
  font-weight: 700;
  color: var(--sdca-navy);
  margin: 0 0 20px;
  line-height: 1.3;
}

/* Suggestion chips */
.sdca-inline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.sdca-chip {
  display: inline-block;
  padding: 9px 16px;
  border: 1.5px solid var(--sdca-chip-border);
  border-radius: 999px;
  background: var(--sdca-chip-bg);
  color: var(--sdca-chip-text);
  font-size: 13.5px;
  font-family: var(--sdca-font);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
  text-align: left;
  line-height: 1.4;
}

.sdca-chip:hover {
  border-color: var(--sdca-teal);
  background: var(--sdca-chip-hover-bg);
  color: var(--sdca-navy);
  transform: translateY(-1px);
}

.sdca-chip:focus-visible {
  outline: 3px solid var(--sdca-teal);
  outline-offset: 2px;
}

/* Text input row */
.sdca-inline-entry {
  display: flex;
  align-items: center;
  max-width: 520px;
  margin: 0 auto;
  border: 1.5px solid var(--sdca-border);
  border-radius: 999px;
  background: var(--sdca-white);
  padding: 6px 6px 6px 18px;
  box-shadow: 0 2px 12px rgba(31, 61, 107, 0.08);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sdca-inline-entry:focus-within {
  border-color: var(--sdca-blue);
  box-shadow: 0 2px 16px rgba(46, 117, 182, 0.15);
}

.sdca-inline-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: var(--sdca-font);
  color: var(--sdca-text);
  min-width: 0;
}

.sdca-inline-input::placeholder { color: #aab; }

.sdca-inline-go {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sdca-navy);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  transition: background 0.15s, transform 0.15s;
}

.sdca-inline-go:hover {
  background: var(--sdca-teal);
  transform: scale(1.05);
}

.sdca-inline-go:focus-visible {
  outline: 3px solid var(--sdca-teal);
  outline-offset: 2px;
}

/* ── Expanded chat panel ─────────────────────────────────────────────────── */
.sdca-inline-chat {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--sdca-border);
  border-radius: 18px;
  background: var(--sdca-white);
  box-shadow: var(--sdca-shadow);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.42s cubic-bezier(0.34, 1.1, 0.64, 1),
              opacity 0.28s ease;
}

.sdca-inline-chat.sdca-inline-open {
  max-height: 580px;
  opacity: 1;
  pointer-events: all;
}

/* Header */
.sdca-inline-chat-header {
  background: var(--sdca-navy);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sdca-inline-chat-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sdca-inline-chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sdca-teal);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sdca-inline-chat-name {
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
}

.sdca-inline-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  display: inline-block;
  margin-left: 6px;
  animation: sdca-pulse 2s ease-in-out infinite;
}

.sdca-inline-reset {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  font-family: var(--sdca-font);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sdca-inline-reset:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

/* Messages */
.sdca-inline-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  min-height: 200px;
  max-height: 360px;
}

.sdca-inline-messages::-webkit-scrollbar { width: 4px; }
.sdca-inline-messages::-webkit-scrollbar-track { background: transparent; }
.sdca-inline-messages::-webkit-scrollbar-thumb { background: var(--sdca-border); border-radius: 4px; }

/* Typing indicator inside inline chat */
.sdca-inline-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 18px 10px;
  flex-shrink: 0;
}

/* Footer */
.sdca-inline-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--sdca-border);
  background: var(--sdca-white);
  flex-shrink: 0;
}

.sdca-inline-reply {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--sdca-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: var(--sdca-font);
  color: var(--sdca-text);
  background: var(--sdca-bg);
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.sdca-inline-reply:focus {
  border-color: var(--sdca-blue);
  background: #fff;
}

.sdca-inline-reply::placeholder { color: #aab; }

.sdca-inline-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sdca-navy);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  transition: background 0.15s, transform 0.15s;
  outline: none;
}

.sdca-inline-send:hover:not(:disabled) {
  background: var(--sdca-teal);
  transform: scale(1.05);
}

.sdca-inline-send:disabled {
  background: #c0cad8;
  cursor: not-allowed;
}

.sdca-inline-send:focus-visible {
  outline: 3px solid var(--sdca-teal);
  outline-offset: 2px;
}

/* Footnote */
.sdca-inline-footnote {
  text-align: center;
  font-size: 11px;
  color: var(--sdca-muted);
  padding: 5px 14px 10px;
  border-top: 1px solid var(--sdca-border);
  flex-shrink: 0;
}

.sdca-inline-footnote a {
  color: var(--sdca-muted);
  text-decoration: underline;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 420px) {
  #sdca-widget {
    bottom: 16px;
    right: 16px;
  }

  #sdca-window {
    width: calc(100vw - 32px);
    right: -8px;
    bottom: 68px;
    max-height: 70vh;
  }
}
