/* ============================================
   猫虾 AI Chat Widget — Styles
   ============================================ */

/* ── Floating Bubble ── */
.maoxia-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green, #7ecf5e);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(126,207,94,0.35), 0 2px 4px rgba(0,0,0,0.08);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.25s;
  font-size: 1.5rem;
  color: #fff;
  line-height: 1;
}
.maoxia-chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(126,207,94,0.45), 0 4px 8px rgba(0,0,0,0.1);
}
.maoxia-chat-bubble:active {
  transform: scale(0.95);
}

/* Badge */
.maoxia-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ff3b30;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(255,59,48,0.4);
  display: none;
}
.maoxia-chat-badge.show { display: flex; }

/* Pulse animation when window closed + unread */
.maoxia-chat-bubble.has-unread {
  animation: maoxia-bubble-pulse 2s ease-in-out infinite;
}
@keyframes maoxia-bubble-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(126,207,94,0.35), 0 2px 4px rgba(0,0,0,0.08); }
  50% { box-shadow: 0 4px 28px rgba(126,207,94,0.55), 0 4px 12px rgba(126,207,94,0.2); }
}

/* ── Chat Window Overlay ── */
.maoxia-chat-overlay {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9997;
  width: 360px;
  height: 500px;
  max-height: calc(100vh - 120px);
  background: var(--surface, #fff);
  border-radius: var(--radius-lg, 20px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  border: 1px solid var(--border, #e5e5e7);
}
.maoxia-chat-overlay.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */
.maoxia-chat-header {
  background: var(--green, #7ecf5e);
  color: #fff;
  padding: 0.9rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
}
.maoxia-chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.maoxia-chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.maoxia-chat-header-text h4 {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}
.maoxia-chat-header-text span {
  font-size: 0.7rem;
  opacity: 0.8;
  font-weight: 400;
}
.maoxia-chat-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.maoxia-chat-close:hover {
  background: rgba(255,255,255,0.35);
}

/* ── Messages Area ── */
.maoxia-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--bg, #f2f2f4);
  scroll-behavior: smooth;
}
.maoxia-chat-messages::-webkit-scrollbar { width: 4px; }
.maoxia-chat-messages::-webkit-scrollbar-track { background: transparent; }
.maoxia-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 2px;
}

/* Message bubbles */
.maoxia-chat-msg {
  max-width: 82%;
  padding: 0.6rem 0.85rem;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.55;
  word-break: break-word;
  animation: maoxia-msg-in 0.3s ease-out;
  position: relative;
}
@keyframes maoxia-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* AI message */
.maoxia-chat-msg.ai {
  align-self: flex-start;
  background: var(--surface, #fff);
  color: var(--text, #1c1c1e);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
  border: 1px solid var(--border, #e5e5e7);
}

/* User message */
.maoxia-chat-msg.user {
  align-self: flex-end;
  background: var(--green, #7ecf5e);
  color: #fff;
  border-bottom-right-radius: 6px;
}

/* System/notice message */
.maoxia-chat-msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-tertiary, #aeaeb2);
  font-size: 0.72rem;
  max-width: 90%;
  text-align: center;
  padding: 0.2rem 0.5rem;
  border: none;
  box-shadow: none;
  animation: none;
}

/* QR inline display */
.maoxia-chat-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.3rem;
  padding: 0.5rem;
  background: var(--bg, #f2f2f4);
  border-radius: var(--radius-sm, 6px);
}
.maoxia-chat-qr img {
  width: 120px;
  height: 120px;
  border-radius: 4px;
}
.maoxia-chat-qr span {
  font-size: 0.75rem;
  color: var(--text-secondary, #6e6e73);
  font-weight: 500;
}

/* ── Typing Indicator ── */
.maoxia-chat-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.6rem 0.85rem;
  background: var(--surface, #fff);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
  border: 1px solid var(--border, #e5e5e7);
}
.maoxia-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary, #aeaeb2);
  animation: maoxia-typing 1.4s ease-in-out infinite;
}
.maoxia-chat-typing span:nth-child(1) { animation-delay: 0s; }
.maoxia-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.maoxia-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes maoxia-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Area ── */
.maoxia-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--border, #e5e5e7);
  background: var(--surface, #fff);
  flex-shrink: 0;
}
.maoxia-chat-input {
  flex: 1;
  border: 1px solid var(--border, #e5e5e7);
  border-radius: 100px;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-family: var(--font, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif);
  outline: none;
  background: var(--bg, #f2f2f4);
  color: var(--text, #1c1c1e);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.maoxia-chat-input:focus {
  border-color: var(--green, #7ecf5e);
  box-shadow: 0 0 0 3px rgba(126,207,94,0.12);
  background: var(--surface, #fff);
}
.maoxia-chat-input::placeholder {
  color: var(--text-tertiary, #aeaeb2);
}
.maoxia-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--green, #7ecf5e);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.maoxia-chat-send:hover {
  background: var(--green-dark, #5cb83a);
}
.maoxia-chat-send:active {
  transform: scale(0.92);
}
.maoxia-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Quick Actions ── */
.maoxia-chat-quick {
  display: flex;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem 0.6rem;
  flex-wrap: wrap;
  background: var(--surface, #fff);
  border-top: 1px solid var(--border, #e5e5e7);
  flex-shrink: 0;
}
.maoxia-chat-quick button {
  font-size: 0.72rem;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  border: 1px solid var(--border, #e5e5e7);
  background: var(--bg, #f2f2f4);
  color: var(--text-secondary, #6e6e73);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
  white-space: nowrap;
}
.maoxia-chat-quick button:hover {
  border-color: var(--green, #7ecf5e);
  color: var(--green-dark, #5cb83a);
  background: var(--green-light, #e8f7e2);
}

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
  .maoxia-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
  }
  .maoxia-chat-overlay {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .maoxia-chat-overlay.open {
    transform: translateY(0) scale(1);
  }
  .maoxia-chat-header {
    padding: 1rem 1.2rem;
  }
  .maoxia-chat-msg {
    max-width: 85%;
    font-size: 0.9rem;
  }
}
