/* ==========================================
 * PRD 原型声明式与可视化批注系统 样式文件 (annotation.css)
 * 支持推移/挤压页面布局模式 (Push Layout) & 只读发布模式
 * ========================================== */

/* 页面容器推移与挤压效果 (当抽屉展开时，页面缩窄 360px，右侧侧边栏完全裸露不遮挡) */
body.annotation-drawer-push .app-container {
  margin-right: 360px !important;
  width: calc(100vw - 360px) !important;
}

.app-container {
  transition: margin-right 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), width 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* 1. 自动注入的标注序号气泡 */
.annotation-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background-color: #1677ff;
  color: #ffffff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(22, 119, 255, 0.4), 0 0 0 2px #ffffff;
  z-index: 100;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
  user-select: none;
}

.annotation-badge:hover {
  transform: scale(1.25);
  background-color: #0958d9;
}

.annotation-badge.active {
  background-color: #f53f3f;
  box-shadow: 0 0 0 3px rgba(245, 63, 63, 0.3), 0 0 0 2px #ffffff;
  transform: scale(1.25);
  animation: pulse-ring 1.5s infinite;
}

/* 高亮闪烁动画 */
@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 63, 63, 0.5), 0 0 0 2px #ffffff;
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 63, 63, 0), 0 0 0 2px #ffffff;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 63, 63, 0), 0 0 0 2px #ffffff;
  }
}

/* 被选中时的目标元素边框闪烁 */
.annotation-target-highlight {
  outline: 2px dashed #f53f3f !important;
  outline-offset: 3px !important;
  border-radius: 4px;
  transition: outline 0.2s ease;
}

/* 2. 贴合在屏幕最右侧边缘的侧边拉手挂件 (绝不入侵 Header 或任何原型 Layout) */
.annotation-side-handle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background-color: #1677ff;
  color: #ffffff;
  border-radius: 8px 0 0 8px;
  padding: 12px 7px;
  box-shadow: -3px 0 14px rgba(22, 119, 255, 0.35);
  z-index: 9998;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: right 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), background-color 0.2s, padding 0.2s;
}

.annotation-side-handle:hover {
  background-color: #0958d9;
  padding-left: 10px;
  box-shadow: -4px 0 18px rgba(22, 119, 255, 0.5);
}

.annotation-side-handle-text {
  writing-mode: vertical-lr; /* 垂直排版文字 "PRD标注" */
  letter-spacing: 2px;
  font-size: 12px;
  font-weight: 600;
}

.annotation-side-handle-badge {
  background-color: #ffffff;
  color: #1677ff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
}

/* 当 Drawer 展开时，侧边拉手跟随滑动到 Drawer 左侧边缘 */
.annotation-side-handle.drawer-open {
  right: 360px; /* 贴在 360px 宽度的 Drawer 左边缘 */
  background-color: #1d2129;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
}

.annotation-side-handle.drawer-open:hover {
  background-color: #272e3b;
}

.annotation-side-handle.drawer-open .annotation-side-handle-badge {
  background-color: #1677ff;
  color: #ffffff;
}

/* 3. 右侧侧滑标注面板 (Drawer) */
.annotation-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background-color: #ffffff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.annotation-drawer.open {
  transform: translateX(0);
}

/* Drawer 头部 */
.annotation-drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e8eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fafafa;
}

.annotation-drawer-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d2129;
  display: flex;
  align-items: center;
  gap: 8px;
}

.annotation-drawer-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #86909c;
  cursor: pointer;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.annotation-drawer-close:hover {
  background-color: #f2f3f5;
  color: #1d2129;
}

/* Drawer 工具栏 (包含 + 新增批注、保存至 dist、重置) */
.annotation-drawer-actions {
  padding: 10px 16px;
  border-bottom: 1px solid #f0f0f0;
  background-color: #ffffff;
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-add-annotation {
  flex: 1;
  height: 32px;
  background-color: #1677ff;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background-color 0.2s;
}

.btn-add-annotation:hover {
  background-color: #0958d9;
}

.btn-export-annotation {
  height: 32px;
  padding: 0 10px;
  background-color: #e6f4ff;
  color: #1677ff;
  border: 1px solid #91caef;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-export-annotation:hover {
  background-color: #1677ff;
  color: #ffffff;
}

.btn-reset-annotation {
  height: 32px;
  padding: 0 10px;
  background-color: #f2f3f5;
  color: #4e5969;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset-annotation:hover {
  background-color: #e5e6eb;
  color: #f53f3f;
}

/* Drawer 内容列表区 */
.annotation-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 标注卡片单条记录 */
.annotation-item {
  background-color: #f8f9fa;
  border: 1px solid #e5e8eb;
  border-radius: 8px;
  padding: 14px;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.annotation-item:hover {
  border-color: #1677ff;
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.08);
  background-color: #ffffff;
}

.annotation-item.active {
  border-color: #f53f3f;
  background-color: #fff7f7;
  box-shadow: 0 2px 8px rgba(245, 63, 63, 0.12);
}

.annotation-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.annotation-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.annotation-item-number {
  width: 20px;
  height: 20px;
  background-color: #1677ff;
  color: #ffffff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.annotation-item.active .annotation-item-number {
  background-color: #f53f3f;
}

.annotation-item-title {
  font-size: 13px;
  font-weight: 600;
  color: #1d2129;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-card-action {
  background: none;
  border: none;
  font-size: 12px;
  color: #86909c;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-card-action:hover {
  background-color: #e5e6eb;
  color: #1677ff;
}

.btn-card-action.btn-delete-card:hover {
  color: #f53f3f;
  background-color: #ffece6;
}

.annotation-item-content {
  font-size: 13px;
  color: #4e5969;
  line-height: 1.5;
  word-break: break-word;
}

/* 4. 点击选元素添加批注提示胶囊 (底部中置悬浮) */
.annotation-picker-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #1677ff;
  color: #ffffff;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(22, 119, 255, 0.35);
  animation: slideUp 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  pointer-events: auto;
}

@keyframes slideUp {
  from { transform: translate(-50%, 100%); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.btn-cancel-picker {
  background-color: rgba(255, 255, 255, 0.25);
  border: none;
  color: #ffffff;
  padding: 4px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s;
}

.btn-cancel-picker:hover {
  background-color: rgba(255, 255, 255, 0.4);
}

/* 拾取模式下悬浮元素外框高亮 */
body.annotation-picker-mode * {
  cursor: crosshair !important;
}

body.annotation-picker-mode .annotation-picker-hover {
  outline: 2px dashed #1677ff !important;
  outline-offset: 2px;
  background-color: rgba(22, 119, 255, 0.05) !important;
}

/* 5. 批注编辑/新增对话弹窗 (Modal) */
.annotation-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

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

.annotation-modal {
  width: 400px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.annotation-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e8eb;
  font-size: 15px;
  font-weight: 600;
  color: #1d2129;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafafa;
}

.annotation-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-label {
  font-size: 13px;
  font-weight: 500;
  color: #4e5969;
}

.modal-input, .modal-textarea {
  width: 100%;
  border: 1px solid #e5e8eb;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  color: #1d2129;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.modal-input:focus, .modal-textarea:focus {
  border-color: #1677ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

.modal-textarea {
  height: 90px;
  resize: vertical;
}

.annotation-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #e5e8eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background-color: #fafafa;
}

.btn-modal-cancel {
  padding: 6px 16px;
  background-color: #f2f3f5;
  border: none;
  border-radius: 6px;
  color: #4e5969;
  font-size: 13px;
  cursor: pointer;
}

.btn-modal-confirm {
  padding: 6px 16px;
  background-color: #1677ff;
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
}

.btn-modal-confirm:hover {
  background-color: #0958d9;
}

/* 6. 只读发布模式 (适用于导出的 dist 部署页：自动隐藏一切新增、编辑与删除控制按钮) */
body[data-annotation-readonly="true"] .annotation-drawer-actions,
body[data-annotation-readonly="true"] .annotation-item-actions {
  display: none !important;
}
