/**
 * ChainTrade Quant - Floating Note Button Styles
 * =====================================================
 * 药丸形浮动按钮（缩小版：100x36）
 * Morphology: Pill-shaped (NOT circular)
 * Position: Fixed bottom-right corner only
 */

:root {
  /* 颜色变量 */
  --note-btn-bg: #16161e;
  --note-btn-border: #00c853;
  --note-btn-border-hover: #00e065;
  --note-btn-glow: rgba(0, 200, 83, 0.15);
  --note-btn-glow-hover: rgba(0, 200, 83, 0.35);
  --note-text: #ffffff;

  /* 按钮几何：缩小版 100x36，圆角18 */
  --note-btn-width: 100px;
  --note-btn-height: 36px;
  --note-btn-radius: 18px;

  /* 文字和图标大小 */
  --note-font-size: 12px;
  --note-icon-size: 14px;

  /* z-index 层级 */
  --note-btn-zindex: 900;
  --modal-overlay-zindex: 3999;
}

/* 关键帧动画 */
@keyframes noteSaveFeedback {
  0% {
    border-color: var(--note-btn-border);
    box-shadow: 0 0 2px var(--note-btn-glow);
  }
  50% {
    border-color: var(--note-btn-border-hover);
    box-shadow: 0 0 8px rgba(0, 224, 101, 0.5);
  }
  100% {
    border-color: var(--note-btn-border);
    box-shadow: 0 0 2px var(--note-btn-glow);
  }
}

@keyframes iconRotateIn {
  from { transform: rotate(0deg); }
  to { transform: rotate(45deg); }
}

@keyframes iconRotateOut {
  from { transform: rotate(45deg); }
  to { transform: rotate(0deg); }
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes btnEntrance {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 基础样式 */
.floating-note-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--note-btn-zindex);
  width: var(--note-btn-width);
  height: var(--note-btn-height);
  border-radius: var(--note-btn-radius);
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background-color: var(--note-btn-bg);
  border: 1.5px solid var(--note-btn-border);
  box-shadow: 0 0 2px var(--note-btn-glow);
  cursor: pointer;
  user-select: none;
  animation: btnEntrance 0.35s ease-out;
  transition: transform 0.25s ease,
              border-color 0.25s ease,
              box-shadow 0.25s ease,
              background-color 0.25s ease;
}

/* 悬停态 */
.floating-note-btn:hover,
.floating-note-btn.is-hover {
  transform: translateY(-2px);
  border-color: var(--note-btn-border-hover);
  box-shadow: 0 0 6px var(--note-btn-glow-hover),
              0 4px 12px rgba(0, 0, 0, 0.3);
}

/* 展开态（弹窗打开时） */
.floating-note-btn.is-expanded {
  border-color: var(--note-btn-border-hover);
  box-shadow: 0 0 6px var(--note-btn-glow-hover);
}
.floating-note-btn.is-expanded .note-icon {
  animation: iconRotateIn 0.3s ease forwards;
}

/* 保存反馈态 */
.floating-note-btn.is-saving .note-icon {
  animation: none;
}
.floating-note-btn.is-saving {
  animation: noteSaveFeedback 0.8s ease forwards;
  pointer-events: none;
}

/* 图标样式 */
.note-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--note-icon-size);
  height: var(--note-icon-size);
  font-size: var(--note-icon-size);
  line-height: 1;
  font-weight: 300;
  color: var(--note-btn-border);
  transition: color 0.25s ease;
  transform-origin: center center;
}
.floating-note-btn:hover .note-icon,
.floating-note-btn.is-hover .note-icon,
.floating-note-btn.is-expanded .note-icon {
  color: var(--note-btn-border-hover);
}
.note-icon.is-checkmark {
  color: var(--note-btn-border-hover);
}

/* 文字样式 */
.note-text {
  font-size: var(--note-font-size);
  font-weight: 600;
  color: var(--note-text);
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* 显示/隐藏状态 */
.floating-note-btn.is-hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.25s ease,
              transform 0.25s ease;
}
.floating-note-btn.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 遮罩层（弹窗背景） */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--modal-overlay-zindex);
  display: none;
  animation: modalFadeIn 0.25s ease-out;
}
.modal-overlay.active {
  display: block;
}

/* 减少动效支持 */
@media (prefers-reduced-motion: reduce) {
  .floating-note-btn {
    animation: none;
    transition: none;
  }
  .floating-note-btn:hover,
  .floating-note-btn.is-hover {
    transform: none;
  }
  .floating-note-btn.is-hidden {
    transform: none;
    opacity: 0;
  }
  .floating-note-btn.is-expanded .note-icon {
    animation: none;
    transform: rotate(45deg);
  }
  .floating-note-btn.is-saving {
    animation: none;
    border-color: var(--note-btn-border-hover);
    box-shadow: 0 0 8px rgba(0, 224, 101, 0.5);
  }
  .modal-overlay {
    animation: none;
  }
}

/* 响应式微调 */
@media (max-width: 768px) {
  .floating-note-btn {
    bottom: 20px;
    right: 20px;
  }
}