/* Melted Crayons Product Chat - Sidebar Interface */

/* Sidebar Tab */
.mc-chat-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #6528F7, #5511F8);
  color: #ffffff;
  padding: 20px 12px;
  border-radius: 12px 0 0 12px;
  cursor: pointer;
  z-index: 999;
  box-shadow: -4px 0 20px rgba(101, 40, 247, 0.3);
  transition: all 0.3s ease;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.mc-chat-tab:hover {
  transform: translateY(-50%) translateX(-5px);
  box-shadow: -6px 0 30px rgba(101, 40, 247, 0.5);
}

.mc-chat-tab .mc-chat-icon {
  margin-bottom: 8px;
  font-size: 18px;
}

/* Chat Drawer */
.mc-chat-drawer {
  position: fixed;
  right: -450px;
  top: 0;
  width: 450px;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(12px);
  box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.mc-chat-drawer.open {
  right: 0;
}

/* Chat Header */
.mc-chat-header {
  padding: 20px;
  background: linear-gradient(135deg, #1a237e, #4a148c);
  color: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mc-chat-header > div {
  flex: 1;
  min-width: 0;
}

.mc-chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  line-height: 1.3;
  color: #ffffff;  
}

.mc-chat-header .mc-chat-subtitle {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 4px;
  line-height: 1.3;
}

.mc-chat-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.mc-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* Product Selector */
.mc-product-selector {
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.mc-selector-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 10px;
  display: block;
}

.mc-product-card {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  margin-bottom: 8px;
}

.mc-product-card:last-child {
  margin-bottom: 0;
}

.mc-product-card:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(66, 165, 245, 0.6);
  transform: translateX(-3px);
}

.mc-product-card.selected {
  background: rgba(66, 165, 245, 0.25);
  border-color: rgba(66, 165, 245, 1);
}

.mc-product-name {
  color: white;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
  line-height: 1.3;
}

.mc-product-role {
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  line-height: 1.3;
}

/* Conversation Area */
.mc-conversation {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}

.mc-conversation::-webkit-scrollbar {
  width: 6px;
}

.mc-conversation::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.mc-conversation::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.mc-message {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
  animation: messageSlide 0.3s ease-out;
  color: white;
  line-height: 1.5;
  font-size: 14px;
}

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

.mc-message.system-message {
  background: rgba(66, 165, 245, 0.3);
  margin: 10px auto;
  text-align: center;
  max-width: 90%;
}

.mc-message.you-message {
  background: rgba(76, 175, 80, 0.3);
  margin-left: auto;
}

.mc-message.assistant-message {
  background: rgba(255, 255, 255, 0.12);
  margin-right: auto;
}

.mc-message.error-message {
  background: rgba(255, 68, 68, 0.3);
}

.mc-message.loading {
  background: rgba(66, 165, 245, 0.3);
  animation: pulse 1.5s infinite;
}

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

/* Input Footer */
.mc-chat-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

.mc-char-counter {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  margin-bottom: 6px;
  display: block;
}

.mc-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.mc-user-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 14px;
  min-height: 42px;
  max-height: 100px;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
}

.mc-user-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.mc-user-input:focus {
  outline: none;
  border-color: rgba(66, 165, 245, 0.6);
  background: rgba(255, 255, 255, 0.12);
}

.mc-send-btn {
  background: linear-gradient(135deg, rgba(66, 165, 245, 0.5), rgba(66, 165, 245, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 10px 20px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mc-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(66, 165, 245, 0.7), rgba(66, 165, 245, 0.9));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(66, 165, 245, 0.4);
}

.mc-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Overlay */
.mc-chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mc-chat-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .mc-chat-drawer {
    width: 100%;
    right: -100%;
  }
  
  .mc-chat-tab {
    font-size: 12px;
    padding: 16px 10px;
  }
  
  .mc-chat-header {
    padding: 16px;
  }
  
  .mc-chat-header h3 {
    font-size: 15px;
    letter-spacing: 1px;
  }
  
  .mc-product-selector {
    padding: 12px;
  }
  
  .mc-selector-label {
    font-size: 12px;
  }
  
  .mc-product-card {
    padding: 10px;
  }
  
  .mc-product-name {
    font-size: 13px;
  }
  
  .mc-product-role {
    font-size: 10px;
  }
  
  .mc-message {
    max-width: 90%;
    font-size: 13px;
  }
  
  .mc-conversation {
    padding: 12px;
  }
  
  .mc-chat-footer {
    padding: 12px;
  }
  
  .mc-user-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Accessibility */
.mc-chat-drawer:focus-within,
.mc-chat-tab:focus {
  outline: 2px solid rgba(66, 165, 245, 0.8);
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid rgba(66, 165, 245, 0.8);
  outline-offset: 2px;
}