/* ESO Chat Widget v1.1 */

/* ── Toggle Button ─────────────────────────────────── */

#eso-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #F26620;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}

#eso-chat-toggle:hover {
  background: #d4551a;
  transform: scale(1.05);
}

#eso-chat-toggle.eso-chat-toggle-active {
  background: #6b7280;
}

/* ── Panel ─────────────────────────────────────────── */

#eso-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9999;
  width: 420px;
  max-height: 600px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s, transform 0.2s;
}

#eso-chat-panel.eso-chat-closed {
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
}

#eso-chat-panel.eso-chat-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────────────────── */

.eso-chat-header {
  background: #F26620;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.eso-chat-header-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.eso-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.8;
}

.eso-chat-close:hover {
  opacity: 1;
}

/* ── Messages Area ─────────────────────────────────── */

.eso-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 300px;
  max-height: 420px;
  background: #f9fafb;
}

.eso-chat-welcome {
  text-align: center;
  color: #6b7280;
  padding: 32px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.eso-chat-welcome strong {
  color: #F26620;
  font-size: 16px;
}

/* ── Message Bubbles ───────────────────────────────── */

.eso-chat-msg {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}

.eso-chat-msg-user {
  align-items: flex-end;
}

.eso-chat-msg-assistant {
  align-items: flex-start;
}

.eso-chat-bubble {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.eso-chat-msg-user .eso-chat-bubble {
  background: #F26620;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.eso-chat-msg-assistant .eso-chat-bubble {
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.eso-chat-bubble p {
  margin: 0 0 8px;
}

.eso-chat-bubble p:last-child {
  margin-bottom: 0;
}

.eso-chat-bubble ul {
  margin: 4px 0;
  padding-left: 18px;
}

.eso-chat-bubble li {
  margin-bottom: 2px;
}

/* ── Typing Indicator ──────────────────────────────── */

.eso-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 18px;
}

.eso-chat-typing span {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: eso-typing 1.2s infinite;
}

.eso-chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.eso-chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes eso-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ── Product Cards (inline in conversation) ────────── */

.eso-chat-product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #F26620;
  border-radius: 0 10px 10px 0;
  padding: 10px 12px;
  margin: 10px 0;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.eso-chat-product-card:hover {
  background: #f3f4f6;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
}

.eso-chat-product-card:first-child {
  margin-top: 12px;
}

.eso-chat-product-card:last-child {
  margin-bottom: 4px;
}

.eso-chat-product-card img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #e5e7eb;
}

.eso-chat-product-info {
  flex: 1;
  min-width: 0;
}

.eso-chat-product-info h4 {
  margin: 0 0 3px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eso-chat-product-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  color: #6b7280;
  margin: 0 0 6px;
}

.eso-chat-product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.eso-chat-product-price {
  font-size: 14px;
  font-weight: 700;
  color: #F26620;
}

.eso-chat-product-link {
  font-size: 12px;
  font-weight: 500;
  color: #F26620;
  white-space: nowrap;
}

.eso-chat-product-card:hover .eso-chat-product-link {
  text-decoration: underline;
}

/* ── Input Area ────────────────────────────────────── */

.eso-chat-input-area {
  display: flex;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

#eso-chat-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

#eso-chat-input:focus {
  border-color: #F26620;
}

#eso-chat-send {
  margin-left: 8px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: #F26620;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#eso-chat-send:hover {
  background: #d4551a;
}

/* ── Footer ────────────────────────────────────────── */

.eso-chat-footer {
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  padding: 6px;
  background: #fff;
  flex-shrink: 0;
}

/* ── Mobile ────────────────────────────────────────── */

@media (max-width: 480px) {
  #eso-chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 84px;
    max-height: calc(100vh - 120px);
    border-radius: 12px;
  }

  #eso-chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

  .eso-chat-messages {
    min-height: 200px;
    max-height: calc(100vh - 280px);
  }

  .eso-chat-product-card img {
    width: 64px;
    height: 64px;
  }
}
