/* ================================================================
   Scout by txted.ai — AI Shopping Assistant
   ================================================================ */

:root {
  --s-primary: #7c3aed;
  --s-primary-light: #a78bfa;
  --s-primary-pale: #c4b5fd;
  --s-primary-dark: #6d28d9;
  --s-primary-soft: rgba(124, 58, 237, 0.08);
  --s-primary-glow: rgba(124, 58, 237, 0.18);

  --s-accent: #06b6d4;
  --s-accent-soft: rgba(6, 182, 212, 0.1);

  --s-bg: #0a0a10;
  --s-bg-secondary: #111118;
  --s-surface: #18181f;
  --s-surface-hover: #1e1e28;
  --s-surface-elevated: #222230;

  --s-text: #f0f0f4;
  --s-text-secondary: #a0a0b4;
  --s-text-muted: #5a5a70;

  --s-border: rgba(255, 255, 255, 0.06);
  --s-border-hover: rgba(255, 255, 255, 0.1);

  --s-gradient-brand: linear-gradient(135deg, #7c3aed 0%, #a78bfa 50%, #06b6d4 100%);
  --s-gradient-user: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  --s-gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(124, 58, 237, 0.12) 0%, transparent 60%);

  --s-radius: 16px;
  --s-radius-sm: 10px;
  --s-radius-lg: 20px;
  --s-radius-xl: 24px;

  --s-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --s-transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--s-bg);
  color: var(--s-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#ucp-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 840px;
  margin: 0 auto;
  position: relative;
  background: var(--s-gradient-glow) no-repeat top center;
}

/* ---- Header ---- */
#ucp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(17, 17, 24, 0.85);
  border-bottom: 1px solid var(--s-border);
  flex-shrink: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
}

.ucp-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ucp-logo-mark {
  width: 42px;
  height: 42px;
  background: var(--s-gradient-brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  position: relative;
}

.ucp-header-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ucp-brand {
  font-size: 18px;
  font-weight: 800;
  color: var(--s-text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.ucp-tagline {
  font-size: 11px;
  font-weight: 500;
  color: var(--s-text-muted);
  letter-spacing: 0.3px;
}

.ucp-header-right {
  display: flex;
  align-items: center;
}

.ucp-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--s-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 100px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--s-border);
}

.ucp-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4b5563;
  display: inline-block;
  transition: all var(--s-transition);
}

.ucp-status.connected {
  color: var(--s-text-secondary);
}

.ucp-status.connected::before {
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

/* ---- Messages area ---- */
#ucp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* ---- Welcome card ---- */
.scout-welcome {
  align-self: center;
  max-width: 480px;
  width: 100%;
  margin-bottom: 8px;
  animation: welcomeFadeIn 0.6s ease-out;
}

.scout-welcome-card {
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: var(--s-radius-xl);
  padding: 32px 28px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.scout-welcome-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--s-gradient-brand);
}

.scout-welcome-brand {
  margin-bottom: 16px;
}

.scout-brand-logo {
  height: 32px;
  width: auto;
  opacity: 0.85;
  filter: brightness(1.1);
}

.scout-welcome-icon {
  width: 56px;
  height: 56px;
  background: var(--s-gradient-brand);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.3);
  display: none;
}

.scout-welcome-icon svg {
  width: 28px;
  height: 28px;
  color: white;
}

.scout-welcome-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--s-text);
  letter-spacing: -0.5px;
  margin-bottom: 2px;
}

.scout-welcome-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--s-primary-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.scout-welcome-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--s-text-secondary);
  margin-bottom: 20px;
}

.scout-welcome-divider {
  height: 1px;
  background: var(--s-border);
  margin: 18px 0 14px;
}

.scout-welcome-prompt {
  font-size: 12px;
  font-weight: 600;
  color: var(--s-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.scout-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scout-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--s-radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--s-border);
  color: var(--s-text-secondary);
  cursor: pointer;
  transition: all var(--s-transition);
  font-family: inherit;
  text-align: left;
}

.scout-action-btn:hover {
  background: var(--s-primary-soft);
  border-color: rgba(124, 58, 237, 0.3);
  color: var(--s-text);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.1);
}

.scout-action-btn:active {
  transform: translateY(0);
}

.scout-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.1);
  color: var(--s-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--s-transition);
}

.scout-action-btn:hover .scout-action-icon {
  background: rgba(124, 58, 237, 0.2);
}

.scout-action-btn:nth-child(2) .scout-action-icon { background: rgba(6, 182, 212, 0.1); color: var(--s-accent); }
.scout-action-btn:nth-child(2):hover .scout-action-icon { background: rgba(6, 182, 212, 0.2); }
.scout-action-btn:nth-child(3) .scout-action-icon { background: rgba(251, 146, 60, 0.1); color: #fb923c; }
.scout-action-btn:nth-child(3):hover .scout-action-icon { background: rgba(251, 146, 60, 0.2); }
.scout-action-btn:nth-child(4) .scout-action-icon { background: rgba(52, 211, 153, 0.1); color: #34d399; }
.scout-action-btn:nth-child(4):hover .scout-action-icon { background: rgba(52, 211, 153, 0.2); }

.scout-action-text {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}

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

/* ---- Message bubbles ---- */
.ucp-msg {
  max-width: 72%;
  padding: 14px 18px;
  line-height: 1.6;
  font-size: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: msgSlideIn 0.25s ease-out;
}

@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ucp-msg--user {
  align-self: flex-end;
  background: var(--s-gradient-user);
  color: #fff;
  border-radius: var(--s-radius) var(--s-radius) 4px var(--s-radius);
  box-shadow: 0 2px 16px rgba(124, 58, 237, 0.25);
  margin-top: 14px;
  font-weight: 450;
}

.ucp-msg--bot {
  align-self: flex-start;
  background: var(--s-surface);
  color: var(--s-text-secondary);
  border-radius: var(--s-radius) var(--s-radius) var(--s-radius) 4px;
  border: 1px solid var(--s-border);
  margin-top: 4px;
}

.ucp-msg--user + .ucp-msg--bot {
  margin-top: 14px;
}

/* Bot avatar indicator */
.ucp-msg--bot {
  position: relative;
}

/* ---- Markdown in bot messages ---- */
.ucp-msg--bot h2 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; color: var(--s-text); }
.ucp-msg--bot h3 { font-size: 14px; font-weight: 600; margin: 12px 0 4px; color: var(--s-text); }
.ucp-msg--bot h4 { font-size: 13px; font-weight: 600; margin: 10px 0 4px; color: var(--s-text); }
.ucp-msg--bot p { margin: 6px 0; }
.ucp-msg--bot ul, .ucp-msg--bot ol { margin: 8px 0; padding-left: 20px; }
.ucp-msg--bot li { margin: 4px 0; }
.ucp-msg--bot li::marker { color: var(--s-text-muted); }
.ucp-msg--bot a { color: var(--s-primary-pale); text-decoration: none; border-bottom: 1px solid rgba(196, 181, 253, 0.25); transition: all var(--s-transition); }
.ucp-msg--bot a:hover { color: #fff; border-color: var(--s-primary-pale); }
.ucp-msg--bot code { background: rgba(255,255,255,0.05); padding: 2px 7px; border-radius: 5px; font-size: 13px; font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; }
.ucp-msg--bot pre { background: #0c0c12; color: #c4c4d0; padding: 14px 16px; border-radius: var(--s-radius-sm); overflow-x: auto; margin: 10px 0; border: 1px solid var(--s-border); }
.ucp-msg--bot pre code { background: none; color: inherit; padding: 0; }
.ucp-msg--bot blockquote { border-left: 3px solid var(--s-primary); padding-left: 14px; color: var(--s-text-secondary); margin: 10px 0; }
.ucp-msg--bot hr { border: none; border-top: 1px solid var(--s-border); margin: 14px 0; }
.ucp-msg--bot strong { font-weight: 600; color: var(--s-text); }
.ucp-msg--bot em { color: var(--s-text-secondary); font-style: italic; }
.ucp-msg--bot table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.ucp-msg--bot th, .ucp-msg--bot td { border: 1px solid var(--s-border); padding: 8px 12px; text-align: left; }
.ucp-msg--bot th { background: rgba(255,255,255,0.03); font-weight: 600; color: var(--s-text); }

/* ---- Typing indicator ---- */
.ucp-typing {
  display: flex;
  gap: 5px;
  padding: 4px 0;
  align-items: center;
}

.ucp-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--s-primary-light);
  animation: scoutPulse 1.4s infinite ease-in-out;
}

.ucp-typing span:nth-child(2) { animation-delay: 0.15s; }
.ucp-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes scoutPulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ---- Tool status ---- */
.ucp-tool-status {
  font-size: 12px;
  color: var(--s-primary-light);
  font-weight: 500;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ucp-tool-status::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--s-primary-light);
  border-top-color: transparent;
  border-radius: 50%;
  animation: scoutSpin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes scoutSpin {
  to { transform: rotate(360deg); }
}

.ucp-still-working {
  font-size: 12px;
  color: var(--s-text-muted);
  font-style: italic;
  margin-top: 8px;
}

/* ---- Product card ---- */
.ucp-product-card {
  background: var(--s-surface-elevated);
  border: 1px solid var(--s-border);
  border-radius: var(--s-radius);
  overflow: hidden;
  margin: 10px 0;
  transition: all var(--s-transition);
}

.ucp-product-card:hover {
  border-color: rgba(124, 58, 237, 0.25);
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.1);
  transform: translateY(-2px);
}

.ucp-product-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.ucp-product-card .ucp-product-info { padding: 14px 16px; }
.ucp-product-card .ucp-product-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--s-text); }
.ucp-product-card .ucp-product-price { color: var(--s-primary-pale); font-weight: 700; font-size: 16px; }
.ucp-product-card a { display: inline-block; margin-top: 10px; color: var(--s-primary-light); font-size: 13px; font-weight: 500; text-decoration: none; }

/* ---- Quick actions ---- */
#ucp-quick-actions {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  flex-wrap: wrap;
  animation: msgSlideIn 0.4s ease-out;
}

#ucp-quick-actions:empty { display: none; }

.ucp-quick-btn {
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: 100px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--s-text-secondary);
  cursor: pointer;
  transition: all var(--s-transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.ucp-quick-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--s-gradient-brand);
  opacity: 0;
  transition: opacity var(--s-transition);
}

.ucp-quick-btn:hover {
  border-color: rgba(124, 58, 237, 0.3);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.15);
}

.ucp-quick-btn:hover::before {
  opacity: 0.12;
}

.ucp-quick-btn:active {
  transform: translateY(0);
}

/* ---- Input area ---- */
#ucp-input-area {
  padding: 16px 20px 10px;
  background: rgba(17, 17, 24, 0.9);
  border-top: 1px solid var(--s-border);
  flex-shrink: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ucp-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: var(--s-radius);
  padding: 6px 6px 6px 18px;
  transition: all var(--s-transition);
}

.ucp-input-wrapper:focus-within {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 3px var(--s-primary-glow), 0 4px 24px rgba(124, 58, 237, 0.08);
}

#ucp-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--s-text);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 9px 0;
}

#ucp-input::placeholder { color: var(--s-text-muted); }

.ucp-input-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

#ucp-send, #ucp-mic {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--s-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--s-radius-sm);
  transition: all var(--s-transition);
  flex-shrink: 0;
}

#ucp-send svg, #ucp-mic svg { width: 18px; height: 18px; }

#ucp-send:hover {
  background: var(--s-gradient-user);
  color: white;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
  transform: scale(1.05);
}

#ucp-mic:hover {
  background: var(--s-surface-hover);
  color: var(--s-text-secondary);
}

#ucp-send:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  background: transparent;
  color: var(--s-text-muted);
  box-shadow: none;
  transform: none;
}

#ucp-mic.active {
  background: #ef4444;
  color: white;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.35);
  animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.35); }
  50% { box-shadow: 0 0 24px rgba(239, 68, 68, 0.5); }
}

.ucp-footer-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--s-text-muted);
  padding: 10px 0 4px;
  letter-spacing: 0.2px;
}

.ucp-footer-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: opacity var(--s-transition);
}

.ucp-footer-brand:hover { opacity: 0.8; }

.ucp-footer-logo {
  height: 18px;
  width: auto;
  filter: brightness(1.2);
  opacity: 0.7;
  transition: opacity var(--s-transition);
}

.ucp-footer-brand:hover .ucp-footer-logo { opacity: 1; }

.ucp-footer-sep {
  color: var(--s-text-muted);
}

.ucp-footer-meta a {
  color: var(--s-text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--s-transition);
}

.ucp-footer-meta a:hover { color: var(--s-primary-light); }

/* ---- Scrollbar ---- */
#ucp-messages::-webkit-scrollbar { width: 5px; }
#ucp-messages::-webkit-scrollbar-track { background: transparent; }
#ucp-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 3px; }
#ucp-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }
#ucp-messages { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.06) transparent; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  #ucp-app { max-width: 100%; }
  #ucp-header { padding: 12px 16px; }
  .ucp-logo-mark { width: 36px; height: 36px; border-radius: 10px; }
  .ucp-logo-mark svg { width: 18px; height: 18px; }
  .ucp-brand { font-size: 16px; }
  .ucp-tagline { display: none; }
  #ucp-messages { padding: 16px 12px; }
  .ucp-msg { max-width: 88%; }
  #ucp-input-area { padding: 12px 12px 6px; }
  #ucp-quick-actions { padding: 0 12px 12px; }
  .ucp-quick-btn { padding: 8px 14px; font-size: 12px; }
  .scout-welcome-card { padding: 24px 20px 22px; }
  .scout-actions { grid-template-columns: 1fr; }
  .scout-welcome-name { font-size: 19px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .ucp-msg { max-width: 78%; }
}

/* ---- Selection ---- */
::selection { background: rgba(124, 58, 237, 0.35); color: var(--s-text); }
