* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  margin: 0;
  padding: 0;
}

#chat-container {
  max-width: 66%;
  margin: 2rem auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  height: 80vh;
  overflow: hidden;
}

@media (max-width: 768px) {
  #chat-container {
    max-width: 95%;
    margin: 1rem auto;
    height: 85vh;
    border-radius: 12px;
  }
}

#case-id-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#case-id-content {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
}

#case-id-value {
  font-family: 'Courier New', monospace;
  font-weight: bold;
  font-size: 15px;
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: all;
  transition: background 0.2s ease;
}

#case-id-value:hover {
  background: rgba(255,255,255,0.3);
}

#copy-feedback {
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
  color: #a8f5a8;
  font-weight: bold;
}

#copy-feedback.show {
  opacity: 1;
}

#case-id-instructions {
  font-size: 11px;
  opacity: 0.9;
  font-style: italic;
}

@media (max-width: 768px) {
  #case-id-header {
    padding: 10px 16px;
  }

  #case-id-content {
    font-size: 13px;
    flex-wrap: wrap;
  }

  #case-id-value {
    font-size: 14px;
  }

  #case-id-instructions {
    font-size: 10px;
  }
}

.product-gallery {
  background: transparent;
  padding: 10px 0;
  margin: 10px 0;
}

.gallery-header {
  margin: 0 0 15px 0;
  font-size: 15px;
  font-weight: 600;
  color: #2d3748;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .gallery-header {
    font-size: 14px;
  }
}

.product-card {
  position: relative;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
  border-color: #667eea;
}

.product-card.selected {
  border-color: #667eea;
  border-width: 3px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.select-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
  z-index: 10;
}

.select-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 8px rgba(102, 126, 234, 0.5);
}

.product-card.selected .select-btn {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.product-card.selected .select-btn::before {
  content: '✓ ';
}

.product-image {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 8px;
}

.product-name {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #2d3748;
  margin-top: 8px;
}

.product-gallery.hidden {
  display: none;
}

#messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
}

#messages::-webkit-scrollbar {
  width: 8px;
}

#messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#messages::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

#messages::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

.message {
  padding: 12px 16px;
  margin: 6px 0;
  border-radius: 18px;
  max-width: 75%;
  word-wrap: break-word;
  word-break: break-word;
  display: block;
  font-size: 15px;
  line-height: 1.5;
  animation: slideIn 0.2s ease-out;
}

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

.message ul.nested-list {
  margin: 4px 0;
  padding-left: 24px;
  list-style-type: circle;
}

.message li {
  margin: 4px 0;
}

@media (max-width: 768px) {
  .message {
    max-width: 85%;
    font-size: 14px;
    padding: 10px 14px;
  }
}

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

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.message.bot {
  align-self: flex-start;
  background-color: #ffffff;
  color: #2d3748;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
}

.message.bot ul {
  margin: 10px 0;
  padding-left: 24px;
}

.message.bot li {
  margin: 6px 0;
}

.message.bot strong {
  font-weight: 600;
  color: #1a202c;
}

.message.bot em {
  font-style: italic;
  color: #4a5568;
}

.color-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
  border: 2px solid #cbd5e0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#input-area {
  display: flex;
  padding: 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  gap: 10px;
  align-items: center;
}

#user-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 150px;
  overflow-y: auto;
  line-height: 1.5;
}

#user-input:focus {
  border-color: #667eea;
}

#user-input::placeholder {
  color: #a0aec0;
  font-size: 14px;
}

#send-btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

#send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

#send-btn:active:not(:disabled) {
  transform: translateY(0);
}

#send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  #input-area {
    padding: 12px;
    gap: 8px;
  }

  #user-input {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 40px;
  }

  #user-input::placeholder {
    font-size: 13px;
  }

  #send-btn {
    padding: 10px 18px;
    font-size: 14px;
    min-width: 60px;
  }
}