/* ── Agente IA Ferretero — Chat Widget ────────────────────────────────────── */

:root {
  --ea-primary:     #e85d04;
  --ea-primary-dk:  #c44d03;
  --ea-surface:     #ffffff;
  --ea-bg:          #f5f5f5;
  --ea-border:      #e0e0e0;
  --ea-text:        #1a1a1a;
  --ea-text-light:  #666666;
  --ea-user-bg:     #fff3e8;
  --ea-bot-bg:      #ffffff;
  --ea-radius:      12px;
  --ea-shadow:      0 8px 32px rgba(0,0,0,0.18);
  --ea-z:           99999;
}

/* Botón flotante */
#ea-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ea-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--ea-shadow);
  z-index: var(--ea-z);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  transition: transform 0.2s, background 0.2s;
  outline: none;
}
#ea-chat-btn:hover { background: var(--ea-primary-dk); transform: scale(1.08); }
#ea-chat-btn .ea-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #e53e3e;
  color: #fff;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  display: none;
}

/* Ventana de chat */
#ea-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 600px;
  background: var(--ea-surface);
  border-radius: var(--ea-radius);
  box-shadow: var(--ea-shadow);
  z-index: var(--ea-z);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border: 1px solid var(--ea-border);
}
#ea-chat-window.ea-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#ea-chat-header {
  background: var(--ea-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#ea-chat-header .ea-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
#ea-chat-header .ea-header-info { flex: 1; min-width: 0; }
#ea-chat-header .ea-agent-name { font-weight: 700; font-size: 15px; }
#ea-chat-header .ea-status {
  font-size: 11px;
  opacity: 0.85;
  display: flex; align-items: center; gap: 4px;
}
#ea-chat-header .ea-status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}
#ea-close-btn {
  background: none; border: none; color: #fff;
  cursor: pointer; font-size: 20px; padding: 4px;
  line-height: 1; opacity: 0.8;
  transition: opacity 0.15s;
}
#ea-close-btn:hover { opacity: 1; }

/* Mensajes */
#ea-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ea-bg);
}
#ea-messages::-webkit-scrollbar { width: 4px; }
#ea-messages::-webkit-scrollbar-track { background: transparent; }
#ea-messages::-webkit-scrollbar-thumb { background: var(--ea-border); border-radius: 4px; }

/* Burbuja de mensaje */
.ea-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: ea-fadein 0.25s ease;
}
.ea-msg.ea-user { margin-left: auto; flex-direction: row-reverse; }
.ea-msg.ea-bot  { margin-right: auto; }

@keyframes ea-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ea-msg-body {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 100%;
  word-break: break-word;
}
.ea-user .ea-msg-body {
  background: var(--ea-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ea-bot .ea-msg-body {
  background: var(--ea-bot-bg);
  color: var(--ea-text);
  border: 1px solid var(--ea-border);
  border-bottom-left-radius: 4px;
}
.ea-msg-body p { margin: 0 0 6px; }
.ea-msg-body p:last-child { margin-bottom: 0; }
.ea-msg-body strong { font-weight: 600; }

/* Tarjetas de producto */
.ea-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.ea-product-card {
  background: var(--ea-surface);
  border: 1px solid var(--ea-border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  gap: 10px;
  text-decoration: none;
  color: var(--ea-text);
  transition: box-shadow 0.15s, border-color 0.15s;
  padding: 8px;
}
.ea-product-card:hover {
  box-shadow: 0 2px 12px rgba(232,93,4,0.15);
  border-color: var(--ea-primary);
}
.ea-product-card img {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #f0f0f0;
}
.ea-product-info { flex: 1; min-width: 0; }
.ea-product-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ea-product-price {
  font-size: 13px;
  color: var(--ea-primary);
  font-weight: 700;
  margin-top: 3px;
}
.ea-product-stock {
  font-size: 11px;
  color: #16a34a;
  margin-top: 1px;
}
.ea-product-stock.ea-out { color: #dc2626; }
.ea-product-cta {
  font-size: 11px;
  color: var(--ea-primary);
  font-weight: 600;
  white-space: nowrap;
  align-self: center;
}

/* Typing indicator */
.ea-typing .ea-msg-body {
  padding: 12px 16px;
}
.ea-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 16px;
}
.ea-typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ea-text-light);
  animation: ea-bounce 1.2s infinite;
}
.ea-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ea-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ea-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
#ea-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--ea-border);
  display: flex;
  gap: 8px;
  background: var(--ea-surface);
  flex-shrink: 0;
}
#ea-input {
  flex: 1;
  border: 1px solid var(--ea-border);
  border-radius: 24px;
  padding: 9px 14px;
  font-size: 14px;
  outline: none;
  resize: none;
  font-family: inherit;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s;
  background: var(--ea-bg);
}
#ea-input:focus { border-color: var(--ea-primary); background: #fff; }
#ea-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--ea-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  align-self: flex-end;
}
#ea-send-btn:hover:not(:disabled) { background: var(--ea-primary-dk); }
#ea-send-btn:disabled { opacity: 0.5; cursor: default; }

/* Sugerencias rápidas */
.ea-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
}
.ea-suggestion {
  background: var(--ea-bg);
  border: 1px solid var(--ea-border);
  border-radius: 16px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ea-text);
  transition: background 0.15s, border-color 0.15s;
}
.ea-suggestion:hover { background: #fff3e8; border-color: var(--ea-primary); color: var(--ea-primary); }

/* Mobile */
@media (max-width: 480px) {
  #ea-chat-window {
    right: 0; bottom: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: var(--ea-radius) var(--ea-radius) 0 0;
  }
  #ea-chat-btn { bottom: 16px; right: 16px; }
}
