/* Mamaegima AI Chat Window - White/Gold Theme */

:root {
  --gold-primary: #D4AF37;
  --gold-light: #F4E4C1;
  --gold-dark: #B8941E;
  --white: #FFFFFF;
  --off-white: #FAFAFA;
  --gray-light: #F5F5F5;
  --gray-medium: #E0E0E0;
  --gray-dark: #757575;
  --text-primary: #212121;
  --text-secondary: #616161;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
}

#mamaegima-chat-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
}

/* Floating Chat Icon */
.chat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
  transition: all 0.3s ease;
}

.chat-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--shadow-hover);
}

.chat-icon svg {
  width: 32px;
  height: 32px;
}

.chat-icon.hidden {
  display: none;
}

/* Chat Window */
.chat-window {
  width: 380px;
  height: 600px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 8px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

.chat-window.hidden {
  display: none;
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
  color: var(--white);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px var(--shadow);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.assistant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white);
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.assistant-avatar svg {
  width: 24px;
  height: 24px;
}

.assistant-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.assistant-status {
  margin: 2px 0 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--off-white);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--gray-light);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--gray-medium);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--gray-dark);
}

/* Message Bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  box-shadow: 0 1px 2px var(--shadow);
  line-height: 1.5;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--white);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--gray-medium);
}

/* Message Content Formatting */
.message-content p {
  margin: 0 0 10px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  font-weight: 600;
  color: var(--gold-dark);
}

.message.user .message-content strong {
  color: var(--white);
}

.message-content em {
  font-style: italic;
}

.message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
  list-style-type: disc;
}

.message-content br {
  line-height: 1.8;
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 8px;
}

.message.user .message-timestamp {
  text-align: right;
}

.message.assistant .message-timestamp {
  text-align: left;
}

/* Message Image Preview */
.message-image {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
  cursor: pointer;
}

.message-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-size: 14px;
}

.welcome-message h4 {
  color: var(--gold-primary);
  margin: 0 0 8px 0;
  font-size: 16px;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--white);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px var(--shadow);
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-dark);
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Attachment Preview */
.attachment-preview {
  padding: 8px 16px;
  background: var(--gold-light);
  border-top: 1px solid var(--gray-medium);
}

.attachment-preview.hidden {
  display: none;
}

.attachment-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-primary);
}

.remove-attachment-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.remove-attachment-btn:hover {
  color: var(--text-primary);
}

/* Chat Input Area */
.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--gray-medium);
}

.chat-input-controls {
  display: flex;
  align-items: center;
  padding: 12px;
  gap: 8px;
}

.chat-input {
  flex: 1;
  border: 1px solid var(--gray-medium);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.chat-input:focus {
  border-color: var(--gold-primary);
}

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
  color: var(--white);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.1);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

.chat-input-controls .icon-btn {
  background: transparent;
  color: var(--gold-primary);
}

.chat-input-controls .icon-btn:hover {
  background: var(--gold-light);
}

.hidden {
  display: none !important;
}

/* File Inputs - Ensure they're completely hidden */
input[type="file"] {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  overflow: hidden !important;
  z-index: -1 !important;
  left: -9999px !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Product Card Styles */
.product-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid var(--gold-primary);
  border-radius: 12px;
  padding: 16px;
  margin: 8px 0;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
  max-width: 100%;
}

.product-card-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gold-light);
}

.product-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-detail {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.5;
}

.product-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 100px;
}

.product-value {
  color: var(--text-primary);
  text-align: right;
  flex: 1;
}

.product-value.in-stock {
  color: #28a745;
  font-weight: 600;
}

.product-value.out-of-stock {
  color: #dc3545;
  font-weight: 600;
}

/* Product Gallery Styles */
.product-gallery {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid var(--gold-primary);
  border-radius: 12px;
  padding: 20px;
  margin: 10px 0;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
}

.gallery-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--gold-light);
}

.gallery-header h4 {
  color: var(--gold-primary);
  font-size: 20px;
  margin: 0 0 8px 0;
  font-weight: 700;
}

.gallery-header p {
  color: #666;
  font-size: 14px;
  margin: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.gallery-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.25);
  border-color: var(--gold-primary);
}

.gallery-item-image {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Aspect Ratio */
  background: #f5f5f5;
  overflow: hidden;
}

.gallery-item-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-item-image img {
  transform: scale(1.1);
}

.stock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.stock-badge.low {
  background: #fff3cd;
  color: #856404;
}

.stock-badge.out {
  background: #f8d7da;
  color: #721c24;
}

.gallery-item-details {
  padding: 12px;
}

.gallery-item-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin: 0 0 6px 0;
  line-height: 1.3;
  height: 36px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.gallery-item-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-primary);
  margin: 0 0 4px 0;
}

.gallery-item-color {
  font-size: 12px;
  color: #666;
  margin: 0 0 4px 0;
}

.gallery-item-sku {
  font-size: 11px;
  color: #999;
  margin: 0;
}

/* Responsive Gallery */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
  
  .gallery-item-details {
    padding: 10px;
  }
  
  .gallery-item-name {
    font-size: 13px;
    height: 34px;
  }
  
  .gallery-item-price {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .product-gallery {
    padding: 15px;
  }
  
  .gallery-header h4 {
    font-size: 18px;
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  #mamaegima-chat-container {
    bottom: 10px;
    right: 10px;
  }

  .chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    border-radius: 12px;
  }

  .chat-icon {
    width: 56px;
    height: 56px;
  }

  .chat-icon svg {
    width: 28px;
    height: 28px;
  }
}

/* Voice Recording & Playback */
.icon-btn.recording {
  background-color: var(--gold-primary) !important;
  color: var(--white) !important;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(212, 175, 55, 0);
  }
}

.voice-message {
  background-color: var(--gray-light) !important;
  padding: 12px !important;
}

.voice-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.message.user .voice-message {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-primary) 100%) !important;
}

.message.user .voice-label {
  color: var(--gold-dark);
}

audio {
  outline: none;
  border-radius: 20px;
}

audio::-webkit-media-controls-panel {
  background-color: var(--white);
  border-radius: 20px;
}

.speaking-indicator {
  text-align: center;
  padding: 12px;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--white) 100%);
  border-radius: 12px;
  margin: 10px auto;
  max-width: 200px;
  font-weight: 500;
  color: var(--gold-dark);
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
