@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.background-effect {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    var(--accent) 0%,
    transparent 50%);
  opacity: 0.06;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
  transition: background 0.5s ease, opacity 0.5s ease;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* Header */
.header {
  margin-bottom: 24px;
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

/* Language Switcher */
.language-switcher {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.lang-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--accent);
  color: white;
}

/* Theme Selector */
.theme-selector {
  position: relative;
}

.theme-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.theme-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  min-width: 140px;
  display: none;
  overflow: hidden;
  z-index: 100;
}

.theme-menu.active {
  display: block;
}

.theme-item {
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.theme-item:hover {
  background: var(--bg-tertiary);
}

.theme-item.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.theme-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Main Content */
.main {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  margin-bottom: 24px;
  gap: 16px;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.hidden {
  transform: translateX(-100%);
  width: 0;
  border: none;
  margin: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-close-btn {
  display: none; /* Hidden by default, shown on mobile */
  padding: 6px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.sidebar-close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.new-chat-btn {
  padding: 6px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.new-chat-btn:hover {
  opacity: 0.9;
}

.sidebar-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.sidebar-chats {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-item {
  padding: 12px;
  margin-bottom: 4px;
  background: var(--bg-primary);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.chat-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

.chat-item.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.chat-item-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item.active .chat-item-title {
  color: white;
}

.chat-item-time {
  font-size: 12px;
  opacity: 0.7;
}

.chat-item-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  background: rgba(255, 0, 0, 0.1);
  color: #ff4444;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item-delete:hover {
  background: rgba(255, 0, 0, 0.2);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.clear-all-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-all-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
  color: #ff4444;
}

.no-chats {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  .sidebar-close-btn {
    display: block; /* Show close button on mobile */
  }
}

.chat-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 100%;
  scroll-behavior: smooth;
}

/* Welcome Message */
.welcome {
  text-align: center;
  max-width: 480px;
  margin: auto;
  padding: 48px 0;
}

.welcome h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.welcome p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

/* Messages */
.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-content {
  background: var(--bg-tertiary);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.5;
  border: 1px solid var(--border);
}

.message.user .message-content {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.message.assistant .message-content {
  background: var(--bg-primary);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  opacity: 0.6;
  animation: typing 1.2s infinite;
}

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

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Product List */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.product-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 16px;
  transition: border-color 0.2s;
}

.product-card:hover {
  border-color: var(--border-hover);
}

.product-image {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 8px;
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.product-header {
  display: contents;
}

.product-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.rating-stars {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: -1px;
}

.product-features {
  font-size: 14px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-badges {
  display: flex;
  gap: 6px;
}

.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.prime {
  background: var(--accent);
  color: white;
}

.product-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* Chat Input */
.chat-input {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.voice-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.voice-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

.voice-btn.listening {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#userInput {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
}

#userInput:focus {
  outline: none;
  border-color: var(--accent);
}

#userInput::placeholder {
  color: var(--text-tertiary);
}

#sendBtn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

#sendBtn:hover:not(:disabled) {
  opacity: 0.9;
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error Message */
.error-message {
  background: #fee;
  color: #c33;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #fcc;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 16px;
    height: auto;
    min-height: 100vh;
  }

  body {
    height: auto;
    overflow: auto;
  }

  .header {
    margin-bottom: 16px;
  }

  .logo {
    font-size: 16px;
  }

  .sidebar-toggle {
    width: 36px;
    height: 36px;
  }

  .language-switcher {
    padding: 3px;
  }

  .lang-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .chat-panel {
    min-height: 500px;
  }

  .chat-messages {
    padding: 16px;
  }

  .welcome {
    padding: 32px 0;
  }

  .welcome h2 {
    font-size: 24px;
  }

  .product-card {
    grid-template-columns: 80px 1fr;
    gap: 12px;
    padding: 12px;
  }

  .product-image {
    width: 80px;
    height: 80px;
  }

  .message {
    max-width: 95%;
  }
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Footer */
.footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-copy {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--text-primary);
}

/* Better text formatting in messages */
.message-content p {
  margin: 0 0 12px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message-content ol,
.message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
}

.message-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Courier New', monospace;
}

@media (max-width: 640px) {
  .footer {
    position: relative;
    margin-top: auto;
    padding: 16px 0;
  }

  .footer-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .footer-copy {
    font-size: 12px;
  }

  .footer-links {
    width: 100%;
    flex-wrap: wrap;
    gap: 12px;
  }

  .footer-link {
    font-size: 12px;
  }
}
