/* ===== DEMO PAGE — AI Chat Interface ===== */
/* Simulates the user's own LLM chat connected to DealClaw via MCP */

.demo-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 72px 1rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== CHAT SHELL ===== */
.demo-chat {
  flex: 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.08);
  background: var(--card-bg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}

/* ===== HEADER — AI Assistant + MCP Status ===== */
.demo-chat-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ai-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.demo-chat-header .info { flex: 1; }
.demo-chat-header .name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}
.mcp-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--success);
  font-weight: 500;
}
.mcp-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: mcpPulse 2s infinite;
}
@keyframes mcpPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.mcp-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: white;
}

/* ===== MESSAGES AREA ===== */
.demo-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
  min-height: 350px;
}

/* ===== MESSAGE BUBBLES ===== */
.chat-msg {
  max-width: 92%;
  animation: msgFadeIn 0.3s ease;
}
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* AI messages — left aligned, no bubble */
.chat-msg.ai {
  align-self: flex-start;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
  padding: 0.1rem 0;
}

/* User messages — right aligned, bubble */
.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  max-width: 80%;
}

/* System / status messages */
.chat-msg.system {
  align-self: center;
  font-size: 0.72rem;
  color: var(--text-light);
  background: var(--bg);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  opacity: 0.8;
}

/* ===== MCP TOOL CALL INDICATOR ===== */
.tool-call {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.72rem;
  color: var(--text-light);
  animation: msgFadeIn 0.3s ease;
  margin: 0.15rem 0;
}
.tool-call .tool-icon {
  font-size: 0.8rem;
  flex-shrink: 0;
}
.tool-call .tool-name {
  font-weight: 600;
  color: #6366F1;
}
html.dark .tool-call .tool-name {
  color: #A5B4FC;
}
.tool-call .tool-status {
  color: var(--success);
}
.tool-call.loading .tool-status {
  animation: toolPulse 1s infinite;
}
@keyframes toolPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0;
  align-self: flex-start;
}
.typing-indicator span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typingBounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ===== PRODUCT CARDS IN CHAT ===== */
.demo-listings {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.5rem 0;
  width: 100%;
}
.demo-listing-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
  animation: cardSlideIn 0.35s ease both;
  cursor: default;
}
.demo-listing-card:nth-child(2) { animation-delay: 0.08s; }
.demo-listing-card:nth-child(3) { animation-delay: 0.16s; }
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.demo-listing-card:hover {
  border-color: var(--accent);
}
.demo-listing-card.recommended {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Card image */
.demo-listing-img {
  height: 110px;
  position: relative;
  overflow: hidden;
  background: #1a1a2e;
}
.demo-listing-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.badge-rec {
  position: absolute;
  top: 0.45rem; left: 0.45rem;
  font-size: 0.58rem; font-weight: 700;
  background: var(--accent); color: white;
  padding: 0.18rem 0.55rem; border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-condition {
  position: absolute;
  top: 0.45rem; right: 0.45rem;
  font-size: 0.58rem; font-weight: 600;
  padding: 0.18rem 0.5rem; border-radius: 20px;
  color: white;
}
.badge-condition--new { background: rgba(16,185,129,0.9); }
.badge-condition--likenew { background: rgba(59,130,246,0.9); }
.badge-condition--good { background: rgba(245,158,11,0.9); }

/* Card content */
.demo-listing-content {
  padding: 0.65rem 0.85rem 0.75rem;
}
.demo-listing-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.demo-listing-name {
  font-size: 0.82rem; font-weight: 700; color: var(--primary);
  line-height: 1.2;
}
.demo-listing-price {
  font-size: 0.9rem; font-weight: 800; color: var(--accent);
  white-space: nowrap;
}
.demo-listing-desc {
  font-size: 0.72rem;
  color: var(--text-light);
  line-height: 1.4;
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.demo-listing-specs {
  display: flex; flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}
.demo-spec-tag {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-light);
}
.demo-listing-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.68rem;
  color: var(--text-light);
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}
.demo-listing-seller { font-weight: 600; color: var(--primary); }
.demo-listing-rating { font-weight: 600; }
.demo-listing-trades { margin-left: auto; opacity: 0.7; }

/* ===== PRODUCT DETAIL (selected product) ===== */
.demo-product-detail {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin: 0.4rem 0;
}
.demo-product-hero {
  height: 160px;
  position: relative;
  overflow: hidden;
  background: #1a1a2e;
}
.demo-product-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.demo-product-hero .badge-condition {
  top: 0.65rem; right: 0.65rem;
  font-size: 0.68rem;
  padding: 0.22rem 0.6rem;
}
.demo-product-info {
  padding: 0.85rem 1rem 1rem;
}
.demo-product-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.1rem;
}
.demo-product-price {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.demo-product-desc {
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 0.6rem;
}
.demo-product-seller {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}
.demo-product-seller-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.2rem;
}
.demo-product-seller-name { font-weight: 700; font-size: 0.82rem; color: var(--primary); }
.demo-product-seller-stats {
  display: flex;
  gap: 0.8rem;
  font-size: 0.68rem;
  color: var(--text-light);
}

/* ===== WALLET / ESCROW CARD ===== */
.demo-wallet {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0.3rem 0;
}
.demo-wallet-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.82rem;
}
.demo-wallet-row + .demo-wallet-row { border-top: 1px solid var(--border); }
.demo-wallet-label { color: var(--text-light); }
.demo-wallet-value { font-weight: 700; color: var(--primary); }
.demo-wallet-value.accent { color: var(--accent); }
.demo-wallet-value.success { color: var(--success); }

/* ===== NEGOTIATION LOG ===== */
.negotiation-line {
  font-size: 0.82rem;
  padding: 0.25rem 0;
  color: var(--text);
  animation: msgFadeIn 0.3s ease;
}
.negotiation-line .agent-name { font-weight: 700; }
.negotiation-line .agent-buyer { color: var(--accent); }
.negotiation-line .agent-seller { color: #6366F1; }

/* ===== DELIVERY PROGRESS ===== */
.delivery-progress {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.4rem 0;
}
.delivery-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1.2s ease;
  width: 0;
}

/* ===== SUMMARY CARD ===== */
.demo-summary {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin: 0.4rem 0;
}
.demo-summary-header {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: white;
  padding: 1rem 1.2rem;
  text-align: center;
}
.demo-summary-header h3 { font-size: 1rem; font-weight: 800; margin-bottom: 0.15rem; }
.demo-summary-header p { font-size: 0.75rem; opacity: 0.8; }
.demo-summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
.demo-stat {
  background: var(--card-bg);
  padding: 0.85rem;
  text-align: center;
}
.demo-stat-value { font-size: 1.15rem; font-weight: 800; color: var(--accent); }
.demo-stat-label { font-size: 0.7rem; color: var(--text-light); margin-top: 0.15rem; }

/* ===== INPUT AREA ===== */
.demo-input-area {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  background: var(--card-bg);
}
.demo-suggestions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.demo-suggestions:empty { margin-bottom: 0; }
.demo-suggestion {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.demo-suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.demo-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
#demoInput {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
#demoInput:focus { border-color: #6366F1; }
#demoInput:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#demoSend {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: none;
  background: #6366F1;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
#demoSend:hover { background: #4F46E5; }
#demoSend:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== CTA AREA (end of demo) ===== */
.demo-cta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.demo-cta .btn {
  flex: 1;
  min-width: 140px;
  text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .demo-container { padding: 68px 0.5rem 1rem; }
  .demo-chat { max-height: calc(100vh - 90px); }
  .demo-messages { min-height: 280px; }
  .demo-listing-img { height: 90px; }
  .demo-product-hero { height: 130px; }
  .demo-suggestions { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.25rem; }
}
