/* Sophie ChatAero Demo Widget */

:root {
  --sophie-dark: #0d1530;
  --sophie-primary: #1a2f6e;
  --sophie-secondary: #2a4a9c;
  --sophie-accent: #3d6fba;
  --sophie-light: #f0e8db;
  --sophie-beige: #f5efe6;
  --sophie-text: #1a2038;
  --sophie-white: #ffffff;
  --sophie-gray: #f5efe6;
  --sophie-border: #e0d5c5;
  --sophie-shadow: 0 8px 32px rgba(26, 47, 110, 0.18);
}

/* ── Widget Container ─────────────────────────────── */
#sophie-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Toggle Button ────────────────────────────────── */
#sophie-toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--sophie-primary) 0%, var(--sophie-secondary) 100%);
  color: var(--sophie-white);
  border: none;
  border-radius: 50px;
  padding: 12px 20px 12px 10px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(26, 47, 110, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

#sophie-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(26, 47, 110, 0.55);
}

#sophie-toggle-btn:active {
  transform: translateY(0);
}

.sophie-toggle-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #e8f0ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: var(--sophie-primary);
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 12px rgba(255,255,255,0.5), inset 0 1px 2px rgba(255,255,255,0.8);
}

.sophie-toggle-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.sophie-toggle-name {
  font-weight: 600;
  font-size: 14px;
}

.sophie-toggle-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  opacity: 0.9;
}

.sophie-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: sophiePulse 2s infinite;
  flex-shrink: 0;
}

/* ── Chat Window ──────────────────────────────────── */
#sophie-chat-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 400px;
  height: 640px;
  background: var(--sophie-beige);
  border-radius: 16px;
  box-shadow: var(--sophie-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(1);
  opacity: 1;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s ease;
  border: 1px solid var(--sophie-border);
}

#sophie-chat-window.sophie-hidden {
  transform: scale(0.05);
  opacity: 0;
  pointer-events: none;
}

/* ── Header ───────────────────────────────────────── */
.sophie-header {
  background: linear-gradient(135deg, var(--sophie-primary) 0%, var(--sophie-secondary) 100%);
  color: var(--sophie-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sophie-avatar-lg {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #e8f0ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--sophie-primary);
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 10px rgba(255,255,255,0.4), inset 0 1px 2px rgba(255,255,255,0.8);
}

.sophie-header-info {
  flex: 1;
  min-width: 0;
}

.sophie-header-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--sophie-white);
}

.sophie-header-subtitle {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.sophie-online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: sophiePulse 2s infinite;
  display: inline-block;
  flex-shrink: 0;
}

#sophie-newchat-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: var(--sophie-white);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

#sophie-newchat-btn svg {
  width: 14px;
  height: 14px;
  stroke: white;
}

#sophie-newchat-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

#sophie-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: var(--sophie-white);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
}

#sophie-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Messages Area ────────────────────────────────── */
#sophie-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 24px;
  scroll-behavior: smooth;
  background: var(--sophie-beige);
  display: flex;
  flex-direction: column;
  gap: 0;
}

#sophie-messages::-webkit-scrollbar {
  width: 4px;
}

#sophie-messages::-webkit-scrollbar-track {
  background: transparent;
}

#sophie-messages::-webkit-scrollbar-thumb {
  background: var(--sophie-border);
  border-radius: 4px;
}

/* ── Message Bubbles ──────────────────────────────── */
.sophie-msg {
  margin-bottom: 12px;
  max-width: 82%;
  animation: sophieFadeInUp 0.25s ease both;
}

.sophie-msg.assistant {
  max-width: 95%;
}

.sophie-msg.assistant {
  align-self: flex-start;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.sophie-msg.user {
  align-self: flex-end;
}

.sophie-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sophie-beige);
  border: 1.5px solid var(--sophie-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--sophie-primary);
  flex-shrink: 0;
  margin-bottom: 18px;
}

.sophie-avatar-logo {
  width: 80%;
  height: 80%;
  object-fit: contain;
  display: block;
  margin: auto;
  position: relative;
  left: 0;
  top: 0px;
}

.sophie-msg-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sophie-msg-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.65;
  word-wrap: break-word;
}

.sophie-msg.assistant .sophie-msg-bubble {
  background: var(--sophie-white);
  color: var(--sophie-text);
  border: 1px solid var(--sophie-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.sophie-msg.user .sophie-msg-bubble {
  background: var(--sophie-primary);
  color: var(--sophie-white);
  border-radius: 16px;
  border-bottom-right-radius: 4px;
}

.sophie-msg-time {
  font-size: 10px;
  color: #a09080;
  padding: 0 4px;
}

.sophie-msg.user .sophie-msg-time {
  text-align: right;
}

/* ── Typing Indicator ─────────────────────────────── */
#sophie-typing {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-bottom: 12px;
  animation: sophieFadeInUp 0.25s ease both;
}

#sophie-typing .sophie-msg-avatar {
  margin-bottom: 0;
}

.sophie-typing-bubble {
  background: var(--sophie-white);
  border: 1px solid var(--sophie-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.sophie-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sophie-secondary);
  animation: sophieBounce 1.2s infinite;
}

.sophie-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.sophie-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

#sophie-typing.sophie-hidden {
  display: none;
}

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

#sophie-input {
  flex: 1;
  border: 1.5px solid var(--sophie-border);
  border-radius: 22px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 110px;
  overflow-y: auto;
  line-height: 1.5;
  color: var(--sophie-text);
  background: var(--sophie-beige);
  transition: border-color 0.2s ease, background 0.2s ease;
}

#sophie-input:focus {
  border-color: var(--sophie-secondary);
  background: var(--sophie-white);
}

#sophie-input::placeholder {
  color: #a09080;
}

#sophie-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sophie-primary);
  color: var(--sophie-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}

#sophie-send-btn:hover {
  background: var(--sophie-secondary);
  transform: scale(1.06);
}

#sophie-send-btn:active {
  transform: scale(0.96);
}

#sophie-send-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: white;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Suggested Questions ──────────────────────────── */
#sophie-suggestions-area {
  flex-shrink: 0;
  background: transparent;
}

#sophie-suggestions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 10px 14px;
}

.sophie-suggestion-pill {
  background: var(--sophie-white);
  color: var(--sophie-text);
  border: 1.5px solid var(--sophie-border);
  border-radius: 50px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: right;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  opacity: 0;
  animation: sophiePillIn 0.3s ease forwards;
}

.sophie-suggestion-pill:nth-child(1) { animation-delay: 0.05s; }
.sophie-suggestion-pill:nth-child(2) { animation-delay: 0.15s; }
.sophie-suggestion-pill:nth-child(3) { animation-delay: 0.25s; }

.sophie-suggestion-pill:hover {
  background: var(--sophie-light);
  border-color: var(--sophie-accent);
  transform: translateY(-1px);
}

.sophie-suggestion-pill:active {
  transform: translateY(0);
}

@keyframes sophiePillIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Demo Badge ───────────────────────────────────── */
.sophie-demo-badge {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.9);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Utility ──────────────────────────────────────── */
.sophie-hidden {
  display: none !important;
}

/* ── Keyframe Animations ──────────────────────────── */
@keyframes sophieFadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sophiePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(74, 222, 128, 0);
  }
}

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

@keyframes sophieSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Streaming Cursor ─────────────────────────────── */
@keyframes sophieCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Powered By Footer ────────────────────────────── */
.sophie-powered-by {
  text-align: center;
  font-size: 10.5px;
  color: #a09080;
  padding: 5px 14px 7px;
  background: var(--sophie-white);
  border-top: 1px solid var(--sophie-border);
  flex-shrink: 0;
}

.sophie-powered-by a {
  color: var(--sophie-primary);
  text-decoration: none;
  font-weight: 600;
}

.sophie-powered-by a:hover {
  text-decoration: underline;
}

/* ── Markdown Rendering ───────────────────────────── */
.sophie-msg-bubble ul {
  margin: 6px 0 2px 0;
  padding-left: 18px;
}

.sophie-msg-bubble li {
  margin-bottom: 3px;
}

.sophie-msg-bubble strong {
  font-weight: 600;
}

.sophie-msg-bubble em {
  font-style: italic;
}

/* ── Responsive / Mobile ──────────────────────────── */
@media (max-width: 480px) {
  #sophie-widget {
    bottom: 0;
    right: 0;
    left: 0;
  }

  #sophie-toggle-btn {
    bottom: 16px;
    right: 16px;
    position: fixed;
  }

  #sophie-chat-window:not(.sophie-hidden) ~ #sophie-toggle-btn {
    display: none;
  }

  #sophie-chat-window {
    position: fixed;
    bottom: 16px;
    right: 16px;
    left: 16px;
    width: calc(100% - 32px);
    height: 70vh;
    border-radius: 16px;
    transform-origin: bottom center;
  }
}
