/**
 * Chat Panel Styling
 * Production-grade chat interface with smooth transitions
 */

/* Chat Panel Container */
.chat-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 90%;
  max-width: 1200px;
  height: 75vh;
  max-height: 750px;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 100;
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}

.chat-panel[data-state="open"] {
  transform: translateY(0);
  opacity: 1;
}

.chat-panel[data-state="closed"] {
  transform: translateY(100%);
  opacity: 0;
}

/* Chat Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--natural-cream);
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  flex-shrink: 0;
}

.chat-title-section {
  flex: 1;
}

.chat-title {
  font-size: 20px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: var(--space-xs);
}

.chat-subtitle {
  font-size: 15px;
  color: #555;
  line-height: 1.5;
  font-weight: 400;
}

.chat-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.chat-close-btn:hover {
  color: var(--tomato-red-primary);
  background: var(--tomato-red-subtle);
  transform: scale(1.1);
}

.close-icon {
  display: block;
  line-height: 1;
}

/* Summary Strip */
.summary-strip {
  padding: var(--space-sm) var(--space-xl);
  background: var(--tomato-red-subtle);
  border-bottom: 1px solid var(--natural-cream);
  flex-shrink: 0;
}

.summary-intro {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-right: var(--space-sm);
  display: inline-block;
}

.summary-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.pill {
  background: white;
  color: var(--tomato-red-primary);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--tomato-red-light);
  display: inline-block;
}

/* Chat Messages Container */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background: linear-gradient(180deg, #FAFAFA 0%, #F5F2F0 100%);
  min-height: 0;
}

/* Smooth scrolling */
.chat-messages {
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--natural-cream);
  border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--tomato-red-light);
  border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--tomato-red-primary);
}

/* Message Wrapper */
.message-wrapper {
  display: flex;
  gap: var(--space-md);
  animation: messageSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.message-wrapper.user {
  flex-direction: row-reverse;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Message Avatar */
.message-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.avatar-icon {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--gradient-hero);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-tomato);
  font-size: 20px;
}

.avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
}

.avatar-status.online {
  background: var(--fresh-green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* Message Content */
.message-content {
  flex: 1;
  max-width: 600px;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
}

.message-sender {
  font-size: 14px;
  font-weight: 700;
  color: #2c3e50;
}

.message-time {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Message Bubble */
.message-bubble {
  background: white;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  line-height: 1.6;
  color: #2c3e50;
  font-weight: 400;
}

.message-bubble.ai {
  border-bottom-left-radius: 4px;
}

.message-bubble.user {
  background: var(--gradient-hero);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-bubble p {
  margin-bottom: var(--space-sm);
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  font-weight: 600;
  color: var(--tomato-red-primary);
}

.message-bubble.user strong {
  color: white;
}

/* Guided Buttons */
.guided-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.guided-btn {
  background: white;
  border: 2px solid var(--tomato-red-primary);
  color: var(--tomato-red-primary);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.guided-btn:hover {
  background: var(--tomato-red-primary);
  color: white;
  transform: translateX(4px);
}

.guided-btn:active {
  transform: translateX(2px) scale(0.98);
}

/* Quick Action Chips */
.quick-action-chips {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  overflow-x: auto;
  border-top: 1px solid var(--natural-cream);
  background: white;
  flex-shrink: 0;
}

.quick-action-chips::-webkit-scrollbar {
  height: 4px;
}

.quick-action-chips::-webkit-scrollbar-track {
  background: var(--natural-cream);
}

.quick-action-chips::-webkit-scrollbar-thumb {
  background: var(--tomato-red-light);
  border-radius: var(--radius-full);
}

.chip {
  background: var(--natural-cream);
  border: none;
  color: var(--text-primary);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chip:hover {
  background: var(--tomato-red-subtle);
  color: var(--tomato-red-primary);
  transform: translateY(-2px);
}

.chip:active {
  transform: translateY(0);
}

/* Chat Input Container */
.chat-input-container {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--natural-cream);
  background: white;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  border: 2px solid var(--natural-cream);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-lg);
  font-size: 16px;
  transition: all 0.2s ease;
  font-family: var(--font-primary);
  color: #2c3e50;
  font-weight: 400;
}

.chat-input:focus {
  outline: none;
  border-color: var(--tomato-red-primary);
  box-shadow: 0 0 0 3px var(--tomato-red-subtle);
}

.chat-input::placeholder {
  color: #999;
  font-weight: 400;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-hero);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-tomato);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-icon {
  width: 20px;
  height: 20px;
}

/* Product Card Inline */
.product-card-inline {
  background: var(--tomato-red-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  animation: slideInFromBottom 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.product-image {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: white;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-details {
  flex: 1;
}

.product-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.tag {
  background: var(--tomato-red-primary);
  color: white;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}

.product-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-md);
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.product-price {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
}

.price-current {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--tomato-red-primary);
}

.price-unit {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.btn-add-to-cart {
  background: var(--gradient-hero);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-add-to-cart:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-tomato);
}

.btn-add-to-cart:active {
  transform: translateY(0);
}

/* Desktop specific */
@media (min-width: 769px) {
  .chat-panel {
    height: 75vh;
    max-height: 750px;
  }
  
  .chat-messages {
    padding: var(--space-lg);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-panel {
    height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  
  .chat-header {
    padding: var(--space-md) var(--space-lg);
  }
  
  .chat-messages {
    padding: var(--space-md);
  }
  
  .summary-strip {
    padding: var(--space-sm) var(--space-lg);
  }
  
  .quick-action-chips {
    padding: var(--space-sm) var(--space-lg);
  }
  
  .chat-input-container {
    padding: var(--space-md) var(--space-lg);
  }
  
  .product-card-inline {
    flex-direction: column;
  }
  
  .product-image {
    width: 100%;
    height: 200px;
  }
}

/* Accessibility */
.chat-close-btn:focus,
.send-btn:focus,
.chip:focus,
.guided-btn:focus {
  outline: 2px solid var(--tomato-red-primary);
  outline-offset: 2px;
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  .guided-btn:hover {
    transform: none;
  }
  
  .guided-btn:active {
    background: var(--tomato-red-primary);
    color: white;
  }
  
  .chip:hover {
    transform: none;
  }
}


/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}


/* Product Recommendation Card */
.product-recommendation-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  margin: 10px 0;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.product-recommendation-card:hover {
  border-color: #e74c3c;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.2);
  transform: translateY(-2px);
}

.product-card-image {
  flex-shrink: 0;
  width: 80px;
  height: 100px;
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-icon {
  font-size: 40px;
}

.product-card-details {
  flex: 1;
}

.product-card-title {
  font-size: 18px;
  font-weight: 700;
  color: #c0392b;
  margin: 0 0 6px 0;
}

.product-card-tagline {
  font-size: 14px;
  color: #555;
  margin: 0 0 12px 0;
  font-weight: 500;
}

.product-card-cta {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.product-card-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.recommendation-footer {
  margin-top: 15px;
  font-size: 15px;
  color: #555;
  font-style: italic;
  font-weight: 400;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .product-recommendation-card {
    flex-direction: column;
    text-align: center;
  }
  
  .product-card-image {
    width: 80px;
    height: 100px;
  }
  
  .product-icon {
    font-size: 40px;
  }
}


/* Product Card Actions */
.product-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.product-card-cta.primary {
  flex: 1;
  min-width: 150px;
}

.product-card-cta.secondary {
  background: white;
  color: #c0392b;
  border: 2px solid #c0392b;
  flex: 1;
  min-width: 150px;
}

.product-card-cta.secondary:hover {
  background: #c0392b;
  color: white;
}

/* Purity Report Card */
.purity-report-card {
  background: white;
  border: 2px solid #27ae60;
  border-radius: 12px;
  padding: 16px;
  margin: 10px 0;
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.15);
}

.purity-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e0e0e0;
}

.purity-icon {
  font-size: 32px;
}

.purity-header h3 {
  flex: 1;
  margin: 0;
  font-size: 20px;
  color: #2c3e50;
}

.verified-badge {
  background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.purity-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.purity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.purity-item:hover {
  background: #e8f5e9;
  transform: translateX(5px);
}

.purity-label {
  font-size: 15px;
  color: #2c3e50;
  font-weight: 600;
}

.purity-value {
  font-size: 15px;
  font-weight: 700;
  color: #c0392b;
}

.purity-value.clean {
  color: #27ae60;
}

.purity-footer {
  background: #e8f5e9;
  padding: 15px;
  border-radius: 8px;
  margin-top: 15px;
}

.purity-footer p {
  margin: 0 0 10px 0;
  font-weight: 600;
  color: #2c3e50;
}

.purity-footer ul {
  margin: 0;
  padding-left: 20px;
  list-style: none;
}

.purity-footer li {
  margin: 8px 0;
  color: #555;
  font-size: 14px;
  line-height: 1.6;
}

.purity-footer li::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  background: #27ae60;
  border-radius: 50%;
  margin-right: 8px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .product-card-actions {
    flex-direction: column;
  }
  
  .product-card-cta.primary,
  .product-card-cta.secondary {
    width: 100%;
  }
  
  .purity-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .purity-value {
    align-self: flex-end;
  }
}
