/* ==========================================================================
   AsherLab 纳西妲 AI 网站助理样式 (Nahida Assistant Widget)
   草系美学：须弥绿 (#8bd45a, #67b346, #d8f45c) + 深邃工坊暗色 (#0c1514, #12211e)
   ========================================================================== */

:root {
  --nh-ast-dendro-bright: #8bd45a;
  --nh-ast-dendro-glow: #d8f45c;
  --nh-ast-dendro-dark: #1d4d4a;
  --nh-ast-dendro-border: rgba(139, 212, 90, 0.35);
  --nh-ast-gold: #f0db93;
  --nh-ast-bg-panel: rgba(13, 23, 21, 0.94);
  --nh-ast-bg-bubble-ai: rgba(26, 56, 51, 0.55);
  --nh-ast-bg-bubble-user: rgba(36, 56, 44, 0.85);
  --nh-ast-text-main: #eaf5ec;
  --nh-ast-text-muted: #9ebba3;
  --nh-ast-radius-lg: 18px;
  --nh-ast-radius-md: 12px;
  --nh-ast-radius-sm: 8px;
}

/* 根容器 */
.nh-assistant-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  font-family: inherit;
  color: var(--nh-ast-text-main);
  box-sizing: border-box;
}

.nh-assistant-root *,
.nh-assistant-root *::before,
.nh-assistant-root *::after {
  box-sizing: inherit;
}

/* --------------------------------------------------------------------------
   悬浮触发按钮
   -------------------------------------------------------------------------- */
.nh-trigger-btn {
  position: relative;
  width: 62px;
  height: 62px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.nh-trigger-btn:hover {
  transform: scale(1.08) translateY(-2px);
}

.nh-trigger-btn:active {
  transform: scale(0.96);
}

.nh-trigger-avatar-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, #204642 0%, #0d1e1c 85%);
  border: 2px solid var(--nh-ast-dendro-bright);
  box-shadow: 0 4px 18px rgba(139, 212, 90, 0.35), 0 0 10px rgba(216, 244, 92, 0.25);
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nh-trigger-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* 呼吸光环 */
.nh-trigger-halo {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px dashed var(--nh-ast-dendro-glow);
  opacity: 0.65;
  animation: nhHaloRotate 14s linear infinite;
  pointer-events: none;
}

@keyframes nhHaloRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 在线绿点 */
.nh-status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: #39e559;
  border: 2px solid #0d1e1c;
  border-radius: 50%;
  box-shadow: 0 0 6px #39e559;
}

/* 初始提示气泡 */
.nh-trigger-tooltip {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(14, 27, 24, 0.94);
  color: var(--nh-ast-dendro-glow);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--nh-ast-dendro-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 10px rgba(139, 212, 90, 0.15);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.96;
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: nhTooltipFloat 3s ease-in-out infinite;
}

.nh-trigger-tooltip::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent rgba(14, 27, 24, 0.94);
}

@keyframes nhTooltipFloat {
  0%, 100% { transform: translateY(-50%); }
  50% { transform: translateY(calc(-50% - 3px)); }
}

/* --------------------------------------------------------------------------
   对话窗口面板 (Chat Panel)
   -------------------------------------------------------------------------- */
.nh-chat-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 100px);
  background: var(--nh-ast-bg-panel);
  border: 1px solid var(--nh-ast-dendro-border);
  border-radius: var(--nh-ast-radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 24px rgba(139, 212, 90, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: nhPanelIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.nh-chat-panel[hidden] {
  display: none !important;
}

@keyframes nhPanelIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 面板顶栏 */
.nh-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(19, 39, 35, 0.85);
  border-bottom: 1px solid rgba(139, 212, 90, 0.2);
  flex-shrink: 0;
}

.nh-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nh-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--nh-ast-dendro-bright);
  object-fit: cover;
}

.nh-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nh-assistant-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--nh-ast-text-main);
  letter-spacing: 0.5px;
}

.nh-role-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(139, 212, 90, 0.16);
  border: 1px solid rgba(139, 212, 90, 0.35);
  color: var(--nh-ast-dendro-glow);
  font-weight: 500;
}

.nh-header-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--nh-ast-text-muted);
}

.nh-leaf-pulse {
  display: inline-block;
  animation: nhPulse 2s infinite ease-in-out;
}

@keyframes nhPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.nh-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nh-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--nh-ast-text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
}

.nh-icon-btn:hover {
  color: var(--nh-ast-text-main);
  background: rgba(139, 212, 90, 0.15);
  border-color: rgba(139, 212, 90, 0.3);
}

.nh-close-btn:hover {
  background: rgba(220, 60, 60, 0.2);
  border-color: rgba(220, 60, 60, 0.4);
  color: #ff9999;
}

/* --------------------------------------------------------------------------
   消息流 (Messages Stream)
   -------------------------------------------------------------------------- */
.nh-messages-stream {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  outline: none;
  scroll-behavior: smooth;
}

/* 滚动条美化 */
.nh-messages-stream::-webkit-scrollbar {
  width: 5px;
}
.nh-messages-stream::-webkit-scrollbar-track {
  background: transparent;
}
.nh-messages-stream::-webkit-scrollbar-thumb {
  background: rgba(139, 212, 90, 0.25);
  border-radius: 4px;
}
.nh-messages-stream::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 212, 90, 0.5);
}

.nh-msg-row {
  display: flex;
  gap: 8px;
  max-width: 90%;
  animation: nhMsgFadeIn 0.24s ease-out;
}

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

.nh-msg-assistant {
  align-self: flex-start;
}

.nh-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.nh-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--nh-ast-dendro-bright);
  flex-shrink: 0;
  margin-top: 2px;
}

.nh-msg-bubble {
  padding: 10px 14px;
  border-radius: var(--nh-ast-radius-md);
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.nh-msg-bubble p {
  margin: 0 0 6px 0;
}
.nh-msg-bubble p:last-child {
  margin-bottom: 0;
}

.nh-msg-bubble a {
  color: var(--nh-ast-dendro-glow);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}
.nh-msg-bubble a:hover {
  color: #fff;
}

.nh-msg-assistant .nh-msg-bubble {
  background: var(--nh-ast-bg-bubble-ai);
  border: 1px solid var(--nh-ast-dendro-border);
  border-top-left-radius: 4px;
  color: var(--nh-ast-text-main);
}

.nh-msg-user .nh-msg-bubble {
  background: var(--nh-ast-bg-bubble-user);
  border: 1px solid rgba(139, 212, 90, 0.4);
  border-top-right-radius: 4px;
  color: #f5fcf7;
}

/* 快速提问标签组 */
.nh-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 38px;
  margin-top: -4px;
  margin-bottom: 6px;
}

.nh-prompt-chip {
  background: rgba(29, 77, 74, 0.4);
  border: 1px solid rgba(139, 212, 90, 0.3);
  color: var(--nh-ast-text-muted);
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nh-prompt-chip:hover {
  background: rgba(139, 212, 90, 0.2);
  border-color: var(--nh-ast-dendro-bright);
  color: var(--nh-ast-dendro-glow);
  transform: translateY(-1px);
}

/* 正在输入动画 */
.nh-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
}

.nh-dot {
  width: 6px;
  height: 6px;
  background: var(--nh-ast-dendro-bright);
  border-radius: 50%;
  opacity: 0.6;
  animation: nhDotBounce 1.2s infinite ease-in-out;
}

.nh-dot:nth-child(2) { animation-delay: 0.2s; }
.nh-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes nhDotBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* --------------------------------------------------------------------------
   面板底栏与输入区域
   -------------------------------------------------------------------------- */
.nh-panel-footer {
  padding: 10px 14px 14px 14px;
  background: rgba(14, 28, 25, 0.95);
  border-top: 1px solid rgba(139, 212, 90, 0.18);
  flex-shrink: 0;
}

.nh-quota-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
}

.nh-quota-pill {
  color: var(--nh-ast-dendro-bright);
  background: rgba(139, 212, 90, 0.12);
  border: 1px solid rgba(139, 212, 90, 0.28);
  padding: 2px 7px;
  border-radius: 10px;
}

.nh-quota-pill.nh-quota-warn {
  color: #ffb74d;
  background: rgba(255, 183, 77, 0.15);
  border-color: rgba(255, 183, 77, 0.35);
}

.nh-quota-pill.nh-quota-empty {
  color: #ff7043;
  background: rgba(255, 112, 67, 0.15);
  border-color: rgba(255, 112, 67, 0.35);
}

.nh-tip-text {
  color: var(--nh-ast-text-muted);
  opacity: 0.75;
  font-size: 10.5px;
}

.nh-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.nh-chat-input {
  flex: 1;
  background: rgba(8, 17, 15, 0.85);
  border: 1px solid rgba(139, 212, 90, 0.3);
  border-radius: 20px;
  color: var(--nh-ast-text-main);
  padding: 9px 14px;
  font-size: 13.5px;
  line-height: 1.4;
  outline: none;
  resize: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-height: 80px;
}

.nh-chat-input:focus {
  border-color: var(--nh-ast-dendro-bright);
  box-shadow: 0 0 10px rgba(139, 212, 90, 0.25);
}

.nh-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--nh-ast-dendro-bright) 0%, #4da732 100%);
  border: none;
  color: #0c1c15;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(139, 212, 90, 0.4);
}

.nh-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(139, 212, 90, 0.6);
}

.nh-send-btn:active {
  transform: scale(0.94);
}

.nh-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   移动端响应式适配 (Mobile Breakpoints <= 800px)
   -------------------------------------------------------------------------- */
@media (max-width: 800px) {
  .nh-assistant-root {
    bottom: 18px;
    right: 18px;
  }

  .nh-trigger-btn {
    width: 54px;
    height: 54px;
  }

  .nh-trigger-tooltip {
    display: none; /* 移动端屏幕空间紧张，隐藏常驻气泡 */
  }

  .nh-chat-panel {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    height: 82vh;
    max-height: 600px;
    border-radius: var(--nh-ast-radius-lg);
  }

  /* 输入框字号必须 >= 16px，避免 iOS 聚焦时整页强制放大（遵循 v2.1 规范） */
  .nh-chat-input {
    font-size: 16px;
  }
}
