/* style.css - 完整版（返回顶部按钮始终显示） */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', '微软雅黑', system-ui, sans-serif;
  background: #f0f2f5;
  color: #1b1b1b;
  min-height: 100vh;
  padding: 20px;
  display: flex;
  justify-content: center;
}

#app {
  max-width: 1200px;
  width: 100%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 28px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
  padding: 28px 32px 24px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
}

/* ===== 主布局 ===== */
.main-wrapper {
  display: flex;
  gap: 28px;
  min-height: 500px;
}

.content-area {
  flex: 1;
  min-width: 0;
}

/* ===== 头部搜索 ===== */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 20px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.search-engine {
  display: flex;
  align-items: center;
  background: #ffffff;
  border-radius: 40px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.04);
  flex: 1;
  min-width: 200px;
  overflow: hidden;
}

.search-engine:focus-within {
  box-shadow: 0 0 0 1px #0078d4;
  border-color: #0078d4;
}

.engine-select {
  background: transparent;
  border: none;
  padding: 10px 8px 10px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1b1b1b;
  outline: none;
  cursor: pointer;
  min-width: 88px;
  border-right: 1px solid #e6e8ec;
}

.search-input {
  flex: 1;
  border: none;
  padding: 10px 12px;
  font-size: 0.95rem;
  background: transparent;
  outline: none;
  color: #1b1b1b;
  min-width: 120px;
}

.search-input::placeholder {
  color: #8a8f98;
}

.search-btn {
  background: transparent;
  border: none;
  padding: 10px 18px 10px 10px;
  font-size: 1.2rem;
  color: #0078d4;
  cursor: pointer;
}

/* ===== 主内容 ===== */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 300px;
}

/* ===== 分类 ===== */
.category {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 14px 18px 16px;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  margin-bottom: 12px;
}

.category-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.category-header-left h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1b1b1b;
}

.category-toggle {
  background: none;
  border: none;
  font-size: 0.9rem;
  color: #6c727b;
  cursor: pointer;
  padding: 0 4px;
  transition: transform 0.2s ease;
}

.category-toggle.collapsed {
  transform: rotate(-90deg);
}

.category-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.category-actions button {
  background: transparent;
  border: none;
  color: #8a8f98;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: none;
}

.category-actions button:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #1b1b1b;
}

.category-actions .delete-cat {
  color: #c42b2b;
}

.edit-mode .category-actions button {
  display: inline-flex;
}

/* ===== 标签网格 ===== */
.bookmark-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 4px 0 0;
}

.bookmark-grid.collapsed {
  display: none;
}

/* ===== 标签卡片 ===== */
.bookmark-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 76px;
  padding: 8px 4px 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: all 0.15s ease;
  cursor: default;
  text-decoration: none;
  color: #1b1b1b;
  position: relative;
}

.bookmark-item:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  transform: translateY(-2px);
}

.bookmark-item .bookmark-icon {
  font-size: 2rem;
  line-height: 1.2;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 120, 212, 0.06);
  border-radius: 8px;
  margin-bottom: 4px;
  overflow: hidden;
}

.bookmark-item .bookmark-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bookmark-item .bookmark-name {
  font-size: 0.7rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
  max-width: 68px;
  word-break: break-word;
}

/* ===== 编辑模式 ===== */
.edit-mode .bookmark-item {
  cursor: grab;
  border: 1px dashed rgba(0, 120, 212, 0.2);
}

.edit-mode .category-header {
  cursor: grab;
}

.bookmark-item .drag-handle {
  display: none;
  position: absolute;
  bottom: 2px;
  left: 4px;
  color: #a0a6b0;
  font-size: 0.6rem;
  cursor: grab;
  padding: 1px 3px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.7);
  opacity: 0.6;
  z-index: 2;
  line-height: 1;
}

.edit-mode .bookmark-item .drag-handle {
  display: block;
}

.bookmark-item .drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.9);
}

.bookmark-item .bookmark-actions-overlay {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  gap: 4px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 30px;
  padding: 2px 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.8);
  z-index: 3;
}

.edit-mode .bookmark-item .bookmark-actions-overlay {
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.edit-mode .bookmark-item.show-actions .bookmark-actions-overlay {
  opacity: 1;
  pointer-events: auto;
}

.bookmark-actions-overlay button {
  background: transparent;
  border: none;
  font-size: 0.7rem;
  padding: 2px 5px;
  border-radius: 16px;
  cursor: pointer;
  color: #3b3b3b;
  transition: background 0.15s ease;
}

.bookmark-actions-overlay button:hover {
  background: rgba(0, 0, 0, 0.06);
}

.bookmark-actions-overlay .edit-bm {
  color: #0078d4;
}

.bookmark-actions-overlay .edit-bm:hover {
  background: rgba(0, 120, 212, 0.1);
}

.bookmark-actions-overlay .delete-bm {
  color: #c42b2b;
}

.bookmark-actions-overlay .delete-bm:hover {
  background: rgba(196, 43, 43, 0.1);
}

/* ===== 底部 ===== */
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.footer-hint {
  font-size: 0.8rem;
  color: #b0b5bd;
}

/* ===== URL提示 ===== */
.url-hint {
  color: #0078d4;
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
}

/* ===== 模态框 ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: 28px;
  padding: 32px 36px 36px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.12);
  position: relative;
  animation: modalSlide 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalSlide {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 22px;
  font-size: 1.8rem;
  font-weight: 300;
  color: #7a7f88;
  cursor: pointer;
}

.modal-content h3 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: #1b1b1b;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  color: #3b3b3b;
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e6e8ec;
  border-radius: 16px;
  font-size: 0.95rem;
  background: #fafbfc;
  font-family: inherit;
  color: #1b1b1b;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #0078d4;
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.08);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: #8a8f98;
}

.icon-input-group {
  display: flex;
  gap: 8px;
}

.icon-input-group input {
  flex: 1;
}

.upload-icon-btn {
  padding: 10px 16px;
  border: 1px solid #0078d4;
  border-radius: 16px;
  background: white;
  color: #0078d4;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

.upload-icon-btn:hover {
  background: #f0f7ff;
}

.icon-preview {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #e6e8ec;
  border-radius: 12px;
  text-align: center;
}

.icon-preview img {
  max-width: 60px;
  max-height: 60px;
  border-radius: 8px;
}

.submit-btn {
  background: #0078d4;
  border: none;
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 1rem;
  font-weight: 500;
  color: white;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
}

.submit-btn:hover {
  background: #005a9e;
}

/* ===== 裁剪模态框 ===== */
.crop-modal-content {
  max-width: 600px;
}

.crop-container {
  margin: 16px 0;
}

.crop-wrapper {
  position: relative;
  width: 100%;
  max-height: 450px;
  overflow: hidden;
  background: #1a1a1a;
  border-radius: 12px;
  border: 2px solid #e6e8ec;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
}

.crop-wrapper img {
  max-width: 100%;
  max-height: 450px;
  display: block;
  transition: transform 0.05s ease;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

.crop-box {
  position: absolute;
  border: 2px solid #0078d4;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  width: 128px;
  height: 128px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  background: rgba(0, 120, 212, 0.05);
  touch-action: none;
}

.crop-box:active {
  cursor: grabbing;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #0078d4;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.crop-handle-nw {
  top: -6px;
  left: -6px;
  cursor: nw-resize;
}
.crop-handle-ne {
  top: -6px;
  right: -6px;
  cursor: ne-resize;
}
.crop-handle-sw {
  bottom: -6px;
  left: -6px;
  cursor: sw-resize;
}
.crop-handle-se {
  bottom: -6px;
  right: -6px;
  cursor: se-resize;
}

.crop-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.crop-controls button {
  padding: 6px 20px;
  border: 1px solid #d0d5dd;
  border-radius: 20px;
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
}

.crop-controls button:hover {
  background: #f0f2f5;
}

.crop-info {
  text-align: center;
  margin-top: 8px;
  font-size: 0.9rem;
  color: #6c727b;
}

.crop-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.crop-actions .btn-secondary {
  flex: 1;
  padding: 12px;
  border: 1px solid #d0d5dd;
  border-radius: 40px;
  background: white;
  cursor: pointer;
  font-size: 1rem;
}

.crop-actions .submit-btn {
  flex: 1;
}

/* ============================================================
   右侧浮动按钮组 - 固定定位
   ============================================================ */
.float-buttons {
  position: fixed !important;
  bottom: 30px !important;
  right: 30px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 10px !important;
  z-index: 9999 !important;
  pointer-events: auto !important;
}

.float-btn {
  position: relative !important;
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  border: none !important;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  cursor: pointer !important;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #3b3b3b !important;
  font-size: 1.2rem !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  flex-shrink: 0 !important;
  pointer-events: auto !important;
}

.float-btn:hover {
  transform: translateY(-3px) scale(1.05) !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15) !important;
  background: #ffffff !important;
}

.float-btn:active {
  transform: scale(0.92) !important;
}

.float-btn .float-btn-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  font-size: 1.2rem !important;
}

/* 可编辑开关按钮 - 默认灰色 + 禁止图标 */
.float-btn.toggle-btn {
  background: rgba(200, 200, 200, 0.5) !important;
  border: 2px solid rgba(200, 200, 200, 0.3) !important;
  position: relative !important;
  transition: all 0.3s ease !important;
}

/* 禁止状态的斜杠图标 - 始终显示，激活时隐藏 */
.float-btn.toggle-btn .float-btn-icon {
  position: relative !important;
}

.float-btn.toggle-btn .float-btn-icon::after {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 130% !important;
  height: 3px !important;
  background: rgba(255, 80, 80, 0.8) !important;
  transform: translate(-50%, -50%) rotate(-45deg) !important;
  border-radius: 2px !important;
  opacity: 1 !important;
  transition: opacity 0.3s ease !important;
}

/* 激活状态 - 蓝色圆框 + 铅笔图标，斜杠消失 */
.float-btn.toggle-btn.active {
  background: rgba(0, 120, 212, 0.15) !important;
  border: 2px solid rgba(0, 120, 212, 0.6) !important;
  box-shadow: 0 0 20px rgba(0, 120, 212, 0.15) !important;
}

.float-btn.toggle-btn.active .float-btn-icon::after {
  opacity: 0 !important;
}

.float-btn.toggle-btn.active:hover {
  background: rgba(0, 120, 212, 0.25) !important;
  border-color: rgba(0, 120, 212, 0.8) !important;
  box-shadow: 0 0 30px rgba(0, 120, 212, 0.25) !important;
}

/* 悬停效果 - 灰色状态 */
.float-btn.toggle-btn:not(.active):hover {
  background: rgba(180, 180, 180, 0.6) !important;
  border-color: rgba(180, 180, 180, 0.5) !important;
}

/* 分隔间距 */
.float-divider {
  height: 12px !important;
  width: 2px !important;
  background: rgba(0, 0, 0, 0.08) !important;
  border-radius: 2px !important;
  flex-shrink: 0 !important;
}

/* ============================================================
   返回顶部按钮 - 始终显示
   ============================================================ */
.float-btn.back-to-top {
  background: rgba(0, 120, 212, 0.9) !important;
  color: white !important;
  box-shadow: 0 4px 16px rgba(0, 120, 212, 0.25) !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
  margin-top: 0 !important;
}

.float-btn.back-to-top:hover {
  background: rgba(0, 120, 212, 1) !important;
  box-shadow: 0 6px 24px rgba(0, 120, 212, 0.35) !important;
}

/* 移除 .show 类的特殊样式（按钮始终显示，不再需要） */

/* 工具提示 */
.float-btn .float-btn-tooltip {
  position: absolute !important;
  right: calc(100% + 12px) !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: rgba(0, 0, 0, 0.8) !important;
  backdrop-filter: blur(8px) !important;
  color: white !important;
  padding: 6px 14px !important;
  border-radius: 8px !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transition: all 0.2s ease !important;
  pointer-events: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.float-btn .float-btn-tooltip::after {
  content: '' !important;
  position: absolute !important;
  left: 100% !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  border: 6px solid transparent !important;
  border-left-color: rgba(0, 0, 0, 0.8) !important;
}

.float-btn:hover .float-btn-tooltip {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(-50%) translateX(4px) !important;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  #app {
    padding: 16px;
  }
  .header {
    flex-direction: column;
    align-items: stretch;
  }
  .search-engine {
    min-width: unset;
  }
  .bookmark-item {
    width: 64px;
    padding: 6px 2px 4px;
  }
  .bookmark-item .bookmark-icon {
    font-size: 1.6rem;
    width: 34px;
    height: 34px;
    border-radius: 6px;
  }
  .bookmark-item .bookmark-name {
    font-size: 0.6rem;
    max-width: 60px;
  }
  .modal-content {
    padding: 20px 16px;
  }
  .crop-modal-content {
    max-width: 100%;
    padding: 16px;
  }
  .crop-wrapper {
    max-height: 300px;
  }
  .crop-wrapper img {
    max-height: 300px;
  }
  
  .float-buttons {
    bottom: 20px !important;
    right: 20px !important;
    gap: 8px !important;
  }
  .float-btn {
    width: 42px !important;
    height: 42px !important;
    font-size: 1rem !important;
  }
  .float-btn .float-btn-icon {
    font-size: 1rem !important;
  }
  .float-btn .float-btn-tooltip {
    font-size: 0.7rem !important;
    padding: 4px 10px !important;
  }
  .float-divider {
    height: 10px !important;
  }
}

@media (max-width: 480px) {
  .float-buttons {
    bottom: 16px !important;
    right: 16px !important;
    gap: 6px !important;
  }
  .float-btn {
    width: 38px !important;
    height: 38px !important;
    font-size: 0.9rem !important;
  }
  .float-btn .float-btn-icon {
    font-size: 0.9rem !important;
  }
  .float-divider {
    height: 8px !important;
  }
  .engine-select {
    min-width: 60px;
    font-size: 0.75rem;
    padding: 8px 4px 8px 12px;
  }
  .search-input {
    font-size: 0.85rem;
    padding: 8px 10px;
  }
  .search-btn {
    padding: 8px 12px 8px 8px;
    font-size: 1rem;
  }
}