* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #1A73E8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --accent: #e8a83e;
  --accent-light: #fdf4e3;
  --success: #2e7d32;
  --bg: #F5F5F5;
  --white: #FFFFFF;
  --text: #222222;
  --text-light: #666666;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.demo-banner {
  width: 100%;
  background: #1A73E8;
  color: white;
  text-align: center;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.chat-container {
  width: 100%;
  max-width: 520px;
  height: calc(100vh - 38px);
  display: flex;
  flex-direction: column;
  background: var(--white);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
  .chat-container {
    height: calc(100vh - 58px);
    margin: 10px auto;
    border-radius: 16px;
    overflow: hidden;
  }
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #1A73E8;
  color: white;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.status {
  font-size: 12px;
  opacity: 0.85;
}

.header-right {
  display: flex;
  align-items: center;
}

.cart-badge {
  position: relative;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.cart-badge:hover {
  background: rgba(255, 255, 255, 0.15);
}

.badge-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: white;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-count.hidden {
  display: none;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  scroll-behavior: smooth;
}

.message {
  display: flex;
  max-width: 88%;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message-content {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.message.bot .message-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
}

.message.user .message-content {
  background: var(--primary);
  color: white;
  border-top-right-radius: 4px;
}

.message-content p {
  margin-bottom: 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}

.message-content ul li {
  padding: 3px 0;
}

.message-content strong {
  font-weight: 600;
}

.message-content code {
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.message-content a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--primary-light);
  transition: border-color 0.2s;
}

.message-content a:hover {
  border-color: var(--primary);
}

/* Product grid & cards */
.product-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.product-card {
  display: flex;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  transition: border-color 0.2s;
}

.product-card:hover {
  border-color: var(--primary);
}

.product-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg);
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-card .product-name {
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-pricing {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.product-card .product-price {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}

.product-card .product-compare {
  color: var(--text-light);
  font-size: 12px;
  text-decoration: line-through;
}

.product-card .product-desc {
  color: var(--text-light);
  font-size: 11px;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Variant selector */
.variant-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.variant-pill {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--text);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.variant-pill:hover:not(:disabled) {
  border-color: var(--primary);
}

.variant-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.variant-pill.sold-out {
  opacity: 0.4;
  text-decoration: line-through;
  cursor: not-allowed;
}

/* Quantity control */
.qty-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.qty-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  font-family: inherit;
  padding: 0;
}

.qty-btn:hover {
  background: var(--primary-light);
}

.qty-value {
  width: 20px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.product-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

.btn-view, .btn-cart {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  border: none;
}

.btn-view {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid transparent;
}

.btn-view:hover {
  border-color: var(--primary);
}

.btn-cart {
  background: var(--primary);
  color: white;
}

.btn-cart:hover {
  background: var(--primary-dark);
}

/* Cart notification */
.cart-notification {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
}

.cart-notif-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.free-delivery-badge {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  margin-left: auto;
}

/* Cart view */
.cart-items-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.cart-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  transition: opacity 0.3s;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.cart-item-detail {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 1px;
}

.btn-remove {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #f0e0e0;
  color: #c44;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  transition: background 0.2s;
  font-family: inherit;
}

.btn-remove:hover {
  background: #c44;
  color: white;
}

.cart-total-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  font-size: 13px;
}

/* Typing indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  align-self: flex-start;
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.4;
  animation: typing 1.4s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* Quick Actions */
.quick-actions {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  background: var(--white);
  border-top: 1px solid var(--border);
  scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar {
  display: none;
}

.quick-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Input Area */
.chat-input-area {
  padding: 12px 16px;
  background: var(--white);
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 6px 6px 14px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
}

textarea {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  padding: 6px 0;
  max-height: 100px;
  outline: none;
}

textarea::placeholder {
  color: #999;
}

.send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.input-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 8px;
}

/* Loading state */
.send-btn.loading {
  pointer-events: none;
}

.send-btn.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Markdown rendering in messages */
.message-content h3,
.message-content h4 {
  margin: 8px 0 4px;
  font-size: 14px;
}

.message-content ol {
  padding-left: 18px;
  margin: 6px 0;
}

.message-content ol li {
  padding: 2px 0;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-container {
    max-width: 100%;
    border-radius: 0;
  }

  .message {
    max-width: 92%;
  }
}

/* Cart total tooltip */
.cart-total-tip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--text);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.cart-badge:hover .cart-total-tip {
  opacity: 1;
}

/* Restart button */
.restart-btn {
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  border: none;
  background: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  margin-left: 4px;
}

.restart-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Restart modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.25s ease;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-align: center;
}

.modal-btn-outline {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.modal-btn-outline:hover {
  background: #f0e0e0;
  border-color: #c44;
  color: #c44;
}

.modal-btn-primary {
  background: var(--primary);
  color: white;
}

.modal-btn-primary:hover {
  background: var(--primary-dark);
}

.modal-close {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

/* Suggested actions */
.suggested-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  animation: fadeIn 0.3s ease;
  max-width: 88%;
}

.suggested-btn {
  padding: 7px 14px;
  border: 1px solid var(--primary);
  border-radius: 20px;
  background: var(--white);
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.suggested-btn:hover {
  background: var(--primary);
  color: white;
}

.suggested-btn:active {
  transform: scale(0.96);
}

/* Checkout button */
.cart-checkout-row {
  margin-top: 10px;
  text-align: center;
}

.message-content .btn-checkout {
  display: inline-block;
  width: 100%;
  padding: 12px 20px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-bottom: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.message-content .btn-checkout:hover {
  background: var(--primary-dark);
  color: white;
  transform: scale(1.02);
}
