/* ================================================
   WOOCOMMERCE AI CHATBOT - FRONTEND STYLES
================================================ */

:root {
  --wac-primary: #9147ff;
  --wac-primary-dark: #7435d4;
  --wac-secondary: #3A68BB;
  --wac-success: #34d399;
  --wac-error: #ef4444;
  --wac-rosa: #ec4899;
  --wac-cyan: #05e0f5;
  --wac-text: #1a1a1a;
  --wac-text-light: #6b7280;
  --wac-bg: #ffffff;
  --wac-bg-gray: #f9fafb;
  --wac-border: #e5e7eb;
  --wac-shadow: 0 10px 40px rgba(0, 0, 60, 0.15);
  --wac-shadow-lg: 0 20px 50px rgba(0, 0, 60, 0.25);
}

/* Container Principal */
.wac-chatbot-container {
  position: fixed;
  z-index: 99999999 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ================================================
   FLOATING BUTTON (Baseado no modelo fornecido)
================================================ */
.wac-chatbot-button {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgb(41 32 140 / 90%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.35),
    0 8px 32px rgba(0, 0, 0, 0.25),
    0 0 0 4px rgba(255, 255, 255, 0.95),
    0 0 40px rgba(41, 32, 140, 0.5);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgb(255 255 255 / 94%);
  z-index: 1;
  overflow: hidden;
}

/* Esconder botão quando chat está aberto */
.wac-chatbot-container.wac-chat-open .wac-chatbot-button {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.wac-chatbot-button:hover {
  transform: translateY(-6px) scale(1.08);
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 16px 48px rgba(0, 0, 0, 0.3),
    0 0 0 6px rgba(255, 255, 255, 1),
    0 0 60px rgba(41, 32, 140, 0.8);
  background: rgb(50 40 160 / 95%);
}

.wac-chatbot-button:active {
  transform: translateY(-2px) scale(0.98);
}

/* Balls Background Animation */
.wac-button-balls {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.wac-balls-wrapper {
  position: absolute;
  width: 100%;
  height: 100%;
  animation: wac-rotate-balls 10s linear infinite;
}

.wac-chatbot-button:hover .wac-balls-wrapper {
  animation-play-state: paused;
}

.wac-ball {
  width: 40px;
  height: 40px;
  position: absolute;
  border-radius: 50%;
  filter: blur(20px);
  opacity: 0.7;
}

.wac-ball-violet {
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--wac-primary);
}

.wac-ball-green {
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--wac-success);
}

.wac-ball-rosa {
  top: 50%;
  left: 5px;
  transform: translateY(-50%);
  background-color: var(--wac-rosa);
}

.wac-ball-cyan {
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  background-color: var(--wac-cyan);
}

/* Eyes */
.wac-button-eyes {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.wac-eye {
  width: 9px;
  height: 20px;
  background-color: #ffffff;
  border-radius: 10px;
  animation: wac-blink 5s infinite;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.wac-eyes-happy {
  display: none;
  color: #fff;
}

.wac-eyes-happy svg {
  width: 28px;
  height: 28px;
  margin: 0 -8px;
}

.wac-chatbot-button:hover .wac-button-eyes {
  display: none;
}

.wac-chatbot-button:hover .wac-eyes-happy {
  display: flex;
}

/* ================================================
   CHAT WINDOW
================================================ */
.wac-chatbot-window {
  position: absolute;
  right: 0;
  bottom: 85px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--wac-bg);
  border-radius: 20px;
  box-shadow: var(--wac-shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  z-index: 999999 !important;
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.wac-chatbot-window.wac-open {
  display: flex;
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Header */
.wac-chat-header {
  background: linear-gradient(135deg, var(--wac-primary) 0%, var(--wac-secondary) 100%);
  padding: 16px 20px;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 70px;
  flex-shrink: 0;
}

.wac-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wac-header-avatar {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.wac-avatar-balls {
  width: 100%;
  height: 100%;
  position: relative;
}

.wac-header-avatar .wac-ball {
  width: 20px;
  height: 20px;
  filter: blur(8px);
}

.wac-header-avatar .wac-ball-violet {
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.wac-header-avatar .wac-ball-green {
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.wac-header-text h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.wac-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wac-status-dot {
  width: 8px;
  height: 8px;
  background: var(--wac-success);
  border-radius: 50%;
  animation: wac-pulse 2s infinite;
}

.wac-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.wac-close-btn::before {
  content: '×';
}

.wac-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Messages Area */
.wac-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--wac-bg-gray);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wac-chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.wac-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.wac-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Message Bubbles */
.wac-message {
  display: flex;
  gap: 10px;
  animation: wac-slide-in 0.3s ease;
}

.wac-message.wac-user {
  flex-direction: row-reverse;
}

.wac-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.wac-message.wac-bot .wac-message-avatar {
  background: linear-gradient(135deg, var(--wac-primary), var(--wac-secondary));
  color: white;
}

.wac-message.wac-user .wac-message-avatar {
  background: var(--wac-border);
  color: var(--wac-text);
}

.wac-message-content {
  max-width: 75%;
}

.wac-message-bubble {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.6;
  word-wrap: break-word;
}

.wac-message.wac-bot .wac-message-bubble {
  background: white;
  color: var(--wac-text);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.wac-message.wac-user .wac-message-bubble {
  background: linear-gradient(135deg, var(--wac-primary) 0%, var(--wac-secondary) 100%);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 12px rgba(145, 71, 255, 0.25);
}

.wac-message-time {
  font-size: 11px;
  color: var(--wac-text-light);
  margin-top: 4px;
  padding: 0 4px;
}

/* Typing Indicator */
.wac-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.wac-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--wac-text-light);
  border-radius: 50%;
  animation: wac-typing 1.4s infinite;
}

.wac-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.wac-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* Product Cards */
.wac-products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.wac-product-card {
  background: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.wac-product-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 24px rgba(145, 71, 255, 0.18);
  border-color: var(--wac-primary);
}

.wac-product-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1/1;
  overflow: hidden;
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
}

.wac-product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}

.wac-product-card:hover .wac-product-image {
  transform: scale(1.08);
}

.wac-out-of-stock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(239, 68, 68, 0.95);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.wac-product-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wac-product-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--wac-text);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.wac-product-category {
  font-size: 10px;
  color: var(--wac-text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.wac-product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--wac-primary);
  margin-top: auto;
}

.wac-product-stock {
  font-size: 11px;
  color: var(--wac-success);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wac-product-stock.out-of-stock {
  color: var(--wac-error);
}

.wac-product-cta {
  font-size: 11px;
  color: var(--wac-primary);
  font-weight: 600;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--wac-border);
  text-align: center;
  transition: color 0.2s;
}

.wac-product-card:hover .wac-product-cta {
  color: var(--wac-primary-dark);
}

/* Input Area */
.wac-chat-input-wrapper {
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(249,250,251,0.8) 50%, white 100%);
  border-top: 1px solid rgba(145, 71, 255, 0.1);
  padding: 20px;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.04);
}

.wac-chat-input-container {
  display: flex;
  gap: 10px;
  align-items: center;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 18px;
  padding: 6px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.wac-chat-input-container:focus-within {
  border-color: var(--wac-primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(145, 71, 255, 0.1), 0 4px 16px rgba(145, 71, 255, 0.15);
  transform: translateY(-1px);
}

.wac-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: all 0.2s;
  max-height: 120px;
  min-height: 20px;
  line-height: 1.5;
  color: var(--wac-text);
}

.wac-chat-input::placeholder {
  color: #9ca3af;
  opacity: 1;
  font-weight: 400;
}

.wac-send-btn {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--wac-primary) 0%, var(--wac-secondary) 100%);
  color: white;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  box-shadow: 0 2px 8px rgba(145, 71, 255, 0.25);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(145, 71, 255, 0.25);
}

.wac-send-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(145, 71, 255, 0.45);
  background: linear-gradient(135deg, rgb(160, 85, 255) 0%, rgb(70, 120, 200) 100%);
}

.wac-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

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

/* Animations */
@keyframes wac-rotate-balls {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes wac-blink {
  0%, 46%, 50%, 96%, 100% { height: 18px; }
  48%, 98% { height: 6px; }
}

@keyframes wac-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes wac-slide-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wac-typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* ================================================
   RESPONSIVE - MOBILE
================================================ */
@media (max-width: 768px) {
  /* Janela do chat ocupa quase tela inteira no mobile */
  .wac-chatbot-window {
    position: fixed;
    top: 10px;
    right: 10px;
    bottom: 80px;
    left: 10px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 16px;
  }
  
  /* Botão flutuante MUITO menor no mobile para não atrapalhar */
  .wac-chatbot-button {
    width: 50px;
    height: 50px;
    box-shadow: 
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 4px 16px rgba(0, 0, 0, 0.2),
      0 0 0 3px rgba(255, 255, 255, 0.95);
  }
  
  .wac-chatbot-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
      0 4px 12px rgba(0, 0, 0, 0.35),
      0 8px 24px rgba(0, 0, 0, 0.25),
      0 0 0 4px rgba(255, 255, 255, 1);
  }
  
  .wac-chatbot-container {
    right: 10px !important;
    left: auto !important;
  }
  
  /* No mobile, quando chat aberto, esconder botão completamente */
  .wac-chatbot-container.wac-chat-open .wac-chatbot-button {
    display: none !important;
  }
  
  /* Ajustar tamanho dos olhos */
  .wac-eye {
    width: 7px;
    height: 16px;
  }
  
  .wac-button-eyes {
    gap: 8px;
  }
  
  .wac-eyes-happy svg {
    width: 22px;
    height: 22px;
  }
  
  /* Balls menores */
  .wac-ball {
    width: 30px;
    height: 30px;
  }
  
  /* Header mais compacto */
  .wac-chat-header {
    padding: 12px 16px;
    min-height: 60px;
  }
  
  .wac-header-avatar {
    width: 36px;
    height: 36px;
  }
  
  .wac-header-text h4 {
    font-size: 15px;
  }
  
  .wac-header-status {
    font-size: 11px;
  }
  
  /* Mensagens com padding menor */
  .wac-chat-messages {
    padding: 12px;
    gap: 12px;
  }
  
  .wac-message-bubble {
    padding: 12px 14px;
    max-width: 85%;
  }
  
  /* Input mais compacto */
  .wac-chat-input-wrapper {
    padding: 12px 14px 14px;
  }
  
  .wac-chat-input-container {
    padding: 4px;
  }
  
  .wac-chat-input {
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .wac-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  
  /* Produtos em 2 colunas no mobile */
  .wac-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .wac-product-card {
    font-size: 13px;
  }
  
  .wac-product-title {
    font-size: 13px;
    -webkit-line-clamp: 2;
  }
  
  .wac-product-price {
    font-size: 15px;
  }
}

/* Ajustes para quando o teclado aparece */
@media (max-width: 768px) and (max-height: 600px) {
  .wac-chatbot-window {
    top: 5px;
    bottom: 5px;
  }
  
  .wac-chat-messages {
    padding: 8px;
  }
  
  .wac-chat-input-wrapper {
    padding: 8px 12px 10px;
  }
  
  .wac-message-bubble {
    padding: 10px 12px;
    font-size: 14px;
  }
}
