/**
 * Honor Forum - 附件管理浮动窗口样式
 */

/* ========== 面板容器 ========== */
.am-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99990;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.am-panel.am-visible {
  display: block;
}

.am-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: amFadeIn 0.2s ease;
}

@keyframes amFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========== 对话框 ========== */
.am-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 680px;
  max-width: 95vw;
  max-height: 85vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: amSlideUp 0.3s ease;
}

@keyframes amSlideUp {
  from { transform: translate(-50%, -45%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}

/* ========== 头部 ========== */
.am-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.am-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  margin-right: 24px;
  white-space: nowrap;
}

.am-tabs {
  display: flex;
  gap: 4px;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 3px;
}

.am-tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.am-tab:hover {
  color: #333;
}

.am-tab.active {
  background: #fff;
  color: #1a73e8;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.am-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: none;
  background: #f5f5f5;
  border-radius: 8px;
  font-size: 16px;
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.am-close:hover {
  background: #eee;
  color: #333;
}

/* ========== 主体 ========== */
.am-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 200px;
}

.am-tab-content {
  display: none;
}

.am-tab-content.active {
  display: block;
}

/* ========== 未使用页签：分类筛选 ========== */
.am-unused-filters {
  margin-bottom: 12px;
}

.am-unused-tabs {
  flex-wrap: wrap;
}

.am-unused-tabs .am-tab {
  padding: 4px 12px;
  font-size: 12px;
}

/* ========== 附件列表 ========== */
.am-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.am-empty {
  text-align: center;
  padding: 48px 20px;
  color: #999;
  font-size: 14px;
}

.am-att-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #fafafa;
  border-radius: 10px;
  border: 1px solid #eee;
  transition: all 0.15s;
}

.am-att-item:hover {
  background: #f0f4ff;
  border-color: #c5d5f7;
}

.am-att-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f0f0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.am-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.am-thumb-icon {
  font-size: 28px;
  color: #999;
}

.am-att-info {
  flex: 1;
  min-width: 0;
}

.am-att-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.am-att-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #888;
}

.am-att-meta span {
  white-space: nowrap;
}

.am-price-tag {
  padding: 2px 8px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.am-price-tag:hover {
  background: #c8e6c9;
}

.am-price-tag.am-price-locked {
  background: #fff3e0;
  color: #e65100;
  cursor: pointer;
}

.am-price-tag.am-price-locked:hover {
  background: #ffe0b2;
}

.am-price-tag.am-price-own {
  background: #e3f2fd;
  color: #1565c0;
  cursor: default;
}

/* ========== 显眼的价格/设价按钮（owner 主动设置售价入口） ========== */
.am-price-btn {
  padding: 3px 10px;
  border: 1px solid #1a73e8;
  background: #fff;
  color: #1a73e8;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

/* "💰 设价"（未设价）：实色背景 + 白字，最显眼，鼓励用户设置售价 */
.am-price-btn:not(.am-price-btn-set):not(.am-price-btn-buy) {
  background: #1a73e8;
  color: #fff;
}

.am-price-btn:not(.am-price-btn-set):not(.am-price-btn-buy):hover {
  background: #1557b0;
  border-color: #1557b0;
}

/* "💰 N 积分"（已设价）：浅蓝边框，hover 实色 */
.am-price-btn.am-price-btn-set:hover {
  background: #1a73e8;
  color: #fff;
}

/* "🔒 N 积分 · 购买"（非 owner 未购）：橙色 */
.am-price-btn.am-price-btn-buy {
  border-color: #ff7a00;
  color: #ff7a00;
}

.am-price-btn.am-price-btn-buy:hover {
  background: #ff7a00;
  color: #fff;
}

/* ========== 插入到文章按钮 ========== */
.am-att-insert {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 8px;
}

.am-insert-btn {
  padding: 6px 12px;
  border: none;
  background: #1a73e8;
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(26, 115, 232, 0.2);
}

.am-insert-btn:hover {
  background: #1557b0;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(26, 115, 232, 0.25);
}

.am-insert-btn:active {
  transform: translateY(0);
}

/* ========== 附件操作按钮 ========== */
.am-att-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.am-action-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: #f0f0f0;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: #666;
}

.am-action-btn:hover {
  background: #e0e0e0;
  color: #333;
}

.am-action-btn.am-action-danger:hover {
  background: #ffebee;
  color: #dc3545;
}

/* ========== 上传区 ========== */
.am-dropzone {
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.am-dropzone.am-dragover {
  border-color: #1a73e8;
  background: #f0f4ff;
}

.am-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.am-dropzone-icon {
  font-size: 40px;
  opacity: 0.6;
}

.am-dropzone p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.am-dropzone-hint {
  font-size: 12px !important;
  color: #999 !important;
}

.am-dropzone-limit {
  font-size: 11px !important;
  color: #1976d2 !important;
  background: #e3f2fd;
  padding: 3px 10px;
  border-radius: 10px;
  margin-top: 4px;
}

/* ========== 上传队列 ========== */
.am-upload-queue {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.am-upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #eee;
  flex-wrap: wrap;
}

.am-upload-icon {
  font-size: 18px;
}

.am-upload-name {
  flex: 1;
  font-size: 13px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-upload-text {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
}

.am-progress {
  width: 100%;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
}

.am-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1a73e8, #4285f4);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.am-upload-item.am-upload-done .am-progress-bar {
  background: #198754;
}

.am-upload-item.am-upload-done .am-upload-text {
  color: #198754;
}

.am-upload-item.am-upload-error .am-progress-bar {
  background: #dc3545;
}

.am-upload-item.am-upload-error .am-upload-text {
  color: #dc3545;
}

/* ========== 上传完成面板 ========== */
.am-upload-complete {
  margin-top: 16px;
  padding: 20px;
  text-align: center;
  background: #e8f5e9;
  border-radius: 10px;
  border: 1px solid #a5d6a7;
  animation: amSlideUpInline 0.3s ease;
}

.am-upload-complete-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.am-upload-complete p {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #2e7d32;
  font-weight: 500;
}

.am-upload-complete .am-btn {
  margin-top: 0;
}

@keyframes amSlideUpInline {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 底部 ========== */
.am-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.am-stats {
  font-size: 12px;
  color: #888;
  display: flex;
  gap: 12px;
}

.am-stats span {
  white-space: nowrap;
}

/* ========== 按钮 ========== */
.am-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.am-btn-primary {
  background: #1a73e8;
  color: #fff;
  margin-top: 12px;
}

.am-btn-primary:hover {
  background: #1557b0;
}

.am-btn-secondary {
  background: #f0f0f0;
  color: #666;
}

.am-btn-secondary:hover {
  background: #e0e0e0;
  color: #333;
}

/* ========== 图片查看器 ========== */
.am-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.am-viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(50, 50, 50, 0.92);
  animation: amFadeIn 0.2s ease;
}

.am-viewer-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1;
  animation: amSlideUp 0.3s ease;
}

.am-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px 10px 0 0;
  color: #333;
  font-size: 14px;
}

.am-viewer-close {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  border-radius: 6px;
  color: #333;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.am-viewer-content img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 0 0 10px 10px;
  object-fit: contain;
}

/* ========== 帖子图片旋风/炫光预览器 (PIV) ========== */
.piv-viewer {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.piv-overlay {
  position: absolute;
  inset: 0;
  background: rgba(50, 50, 50, 0.92);
  animation: pivFadeIn 0.2s ease-out;
}

/* 单层旋转光环（去掉 ::after 第二层 + blur，大幅减少 GPU 开销）*/
.piv-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    conic-gradient(from 0deg at 50% 50%,
      transparent 0deg,
      rgba(150, 150, 150, 0.12) 40deg,
      transparent 90deg,
      rgba(170, 170, 170, 0.12) 170deg,
      transparent 230deg,
      rgba(160, 160, 160, 0.1) 310deg,
      transparent 360deg);
  animation: pivSpin 18s linear infinite;
  pointer-events: none;
  will-change: transform;
}

@keyframes pivSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes pivFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pivPop {
  0%   { opacity: 0; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1); }
}

.piv-box {
  position: relative;
  z-index: 2;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: pivPop 0.25s ease-out;
}

.piv-img-wrap {
  max-width: 92vw;
  max-height: 82vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 14px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.08);
}

.piv-img {
  max-width: calc(92vw - 20px);
  max-height: calc(82vh - 20px);
  border-radius: 8px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.piv-title {
  margin-top: 10px;
  padding: 6px 14px;
  max-width: 80vw;
  color: #555;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.piv-close,
.piv-zoom {
  position: absolute;
  z-index: 3;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #ffffff;
  color: #333;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.06);
}
.piv-close:hover,
.piv-zoom:hover {
  transform: scale(1.08);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.08);
  background: #f5f5f5;
}

.piv-close {
  top: -14px;
  right: -14px;
}

.piv-zoom-in  { top: -14px; right: 34px; }
.piv-zoom-out { top: -14px; right: 82px; }

/* 加载 spinner */
.piv-spinner {
  position: absolute;
  z-index: 4;
  width: 56px;
  height: 56px;
  display: none;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #ccc;
  border-right-color: #ddd;
  animation: pivSpin 0.9s linear infinite;
  will-change: transform;
}

/* ========== Toast ========== */
.am-toast {
  position: fixed;
  top: 78px;
  right: 20px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  z-index: 99999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: amSlideIn 0.3s ease;
  transition: opacity 0.3s;
}

.am-toast.am-toast-out {
  opacity: 0;
}

.am-toast-success {
  background: #198754;
}

.am-toast-error {
  background: #dc3545;
}

.am-toast-info {
  background: #1a73e8;
}

@keyframes amSlideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== 触发按钮 ========== */
.am-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
}

.am-trigger-btn:hover {
  background: #e8e8e8;
  color: #333;
  border-color: #ccc;
}

.am-trigger-btn .am-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #1a73e8;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .am-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
    animation: amSlideUpMobile 0.3s ease;
  }

  @keyframes amSlideUpMobile {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .am-header {
    padding: 12px 14px;
  }

  .am-title {
    font-size: 16px;
    margin-right: 12px;
  }

  .am-body {
    padding: 12px 14px;
  }

  .am-footer {
    padding: 10px 14px;
  }

  .am-stats {
    gap: 8px;
    font-size: 11px;
  }
}
