/**
 * 书签系统样式
 */

/* 书签面板 */
.bookmarks-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  width: 400px;
  max-height: calc(100vh - 80px);
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bookmarks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.bookmarks-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.bookmarks-actions {
  display: flex;
  gap: 8px;
}

.bookmarks-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: white;
}

.bookmarks-search {
  margin-bottom: 12px;
}

.bookmarks-search .search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.bookmarks-search .search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.bookmarks-filters {
  display: flex;
  gap: 8px;
}

.bookmarks-filters select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  background: white;
  outline: none;
}

.bookmarks-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.bookmarks-list {
  padding: 0;
}

/* 书签卡片 */
.bookmark-card {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bookmark-card:hover {
  background-color: #f9fafb;
}

.bookmark-card:last-child {
  border-bottom: none;
}

.bookmark-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.bookmark-title-section {
  flex: 1;
  min-width: 0;
}

.bookmark-title {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.bookmark-title:hover {
  color: #3b82f6;
}

.bookmark-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: #6b7280;
}

.bookmark-category {
  font-weight: 500;
}

.bookmark-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.bookmark-card:hover .bookmark-actions {
  opacity: 1;
}

.bookmark-action {
  padding: 4px;
  border: none;
  background: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.bookmark-action:hover {
  background-color: #e5e7eb;
}

.bookmark-description {
  margin-bottom: 8px;
  font-size: 13px;
  color: #4b5563;
  line-height: 1.4;
}

.bookmark-preview {
  margin-bottom: 8px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bookmark-tags {
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bookmark-tag {
  padding: 2px 6px;
  background: #e5e7eb;
  color: #374151;
  font-size: 11px;
  border-radius: 3px;
}

.bookmark-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #9ca3af;
}

/* 空状态 */
.bookmarks-empty {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
}

.bookmarks-empty .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.bookmarks-empty h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #374151;
}

.bookmarks-empty p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

/* 书签按钮状态 */
.btn-editor.active {
  background-color: #3b82f6;
  color: white;
}

.btn-editor.active:hover {
  background-color: #2563eb;
}

/* 书签计数 */
.bookmark-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
  transition: all 0.2s ease;
}

.bookmark-count-animate {
  animation: bookmarkCountPulse 0.3s ease;
}

@keyframes bookmarkCountPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); background: #dc2626; }
  100% { transform: scale(1); }
}

/* 文档管理中的书签状态 */
.document-bookmarked {
  border-left: 3px solid #f59e0b !important;
}

.document-bookmarked .document-title {
  color: #d97706;
}

.document-bookmarked::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #f59e0b;
  border-radius: 50%;
  z-index: 1;
}

/* 模态框中的分类输入组 */
.category-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.category-input-group select,
.category-input-group input {
  flex: 1;
}

.category-input-group .btn {
  flex-shrink: 0;
}

/* 内容预览 */
.content-preview {
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
}

/* 分类管理 */
.category-management-toolbar {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.categories-list {
  max-height: 400px;
  overflow-y: auto;
}

.category-management-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.category-management-item:hover {
  border-color: #d1d5db;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.category-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.category-icon-name {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.category-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.category-details {
  flex: 1;
  min-width: 0;
}

.category-name {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-description {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.category-stats .bookmark-count {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.category-stats .category-date {
  font-size: 12px;
  color: #9ca3af;
}

.category-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.category-action {
  padding: 6px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.category-action:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

.category-action.btn-danger:hover {
  background-color: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

.empty-categories {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
  font-size: 14px;
}

/* 搜索高亮 */
.search-highlight {
  background-color: #fef3c7;
  color: #92400e;
  padding: 1px 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* 搜索统计 */
.search-stats {
  padding: 8px 20px;
  background: #f0f9ff;
  border-bottom: 1px solid #e0f2fe;
  font-size: 12px;
  color: #0369a1;
  text-align: center;
}

.search-stats.no-results {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

/* 书签管理对话框 */
.bookmark-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  padding: 20px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.stat-item {
  text-align: center;
  flex: 1;
}

.stat-number {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #6b7280;
}

.management-actions {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.action-group h4 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.action-buttons {
  display: flex;
  gap: 12px;
}

.action-buttons .btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
}

/* 导入选项 */
.import-info {
  margin-bottom: 20px;
  padding: 16px;
  background: #f0f9ff;
  border: 1px solid #e0f2fe;
  border-radius: 6px;
}

.import-info p {
  margin: 0 0 8px 0;
  font-weight: 600;
  color: #0369a1;
}

.import-info ul {
  margin: 0;
  padding-left: 20px;
  color: #0369a1;
}

.import-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

/* 统计对话框 */
.statistics-grid {
  display: grid;
  gap: 24px;
}

.stats-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 8px;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.stats-card {
  text-align: center;
  padding: 20px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.2s;
}

.stats-card:hover {
  background: #f3f4f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.stats-number {
  font-size: 28px;
  font-weight: 700;
  color: #3b82f6;
  margin-bottom: 4px;
}

.stats-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

.stats-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f0f9ff;
  border: 1px solid #e0f2fe;
  border-radius: 6px;
}

.timeline-label {
  font-size: 14px;
  color: #0369a1;
  font-weight: 500;
}

.timeline-value {
  font-size: 14px;
  color: #0c4a6e;
  font-weight: 600;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 4px;
}

.stats-bookmark-title {
  font-size: 13px;
  color: #92400e;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}

.stats-access-count {
  font-size: 12px;
  color: #78350f;
  font-weight: 600;
  background: #f59e0b;
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 40px;
  text-align: center;
}

.stats-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats-category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.stats-category-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.stats-category-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stats-category-name {
  font-size: 14px;
  color: #374151;
  font-weight: 500;
}

.stats-category-count {
  font-size: 13px;
  color: #6b7280;
  font-weight: 600;
  background: #f3f4f6;
  padding: 4px 8px;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
}

/* 加载状态 */
.bookmark-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #6b7280;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f4f6;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 14px;
  color: #9ca3af;
}

/* 虚拟滚动 */
.virtual-scroll-container {
  overflow: hidden;
}

.virtual-scroll-content {
  will-change: transform;
}

/* 响应式统计 */
@media (max-width: 768px) {
  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-card {
    padding: 16px 12px;
  }
  
  .stats-number {
    font-size: 24px;
  }
}

/* 快捷键提示 */
.keyboard-shortcuts {
  margin-top: 16px;
  padding: 8px 12px;
  background: #f3f4f6;
  border-radius: 4px;
  text-align: center;
}

.keyboard-shortcuts small {
  color: #6b7280;
  font-size: 11px;
}

/* 右键菜单 */
.bookmark-context-menu {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  min-width: 160px;
  font-size: 14px;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.context-menu-item:hover {
  background-color: #f3f4f6;
}

.context-menu-item.context-menu-danger:hover {
  background-color: #fef2f2;
  color: #dc2626;
}

.context-menu-separator {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

.menu-icon {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.menu-text {
  flex: 1;
}

/* 拖拽样式 */
.bookmark-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.bookmark-card.drag-over {
  border: 2px dashed #3b82f6;
  background-color: #eff6ff;
}

.bookmark-card[draggable="true"] {
  cursor: move;
}

.bookmark-card[draggable="true"]:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 移动端关闭按钮 */
.mobile-close-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  font-size: 20px;
  font-weight: bold;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-close-btn:hover {
  background: rgba(0, 0, 0, 0.2);
  color: #374151;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .bookmarks-panel.mobile-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  .bookmarks-panel.mobile-fullscreen .mobile-close-btn {
    display: block;
  }
  
  .bookmarks-panel.mobile-fullscreen .bookmarks-header {
    padding: 16px 20px 16px 20px;
    position: relative;
  }
  
  .bookmark-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .bookmark-actions {
    opacity: 1;
    position: static;
    margin-top: 8px;
  }
  
  .bookmarks-filters {
    flex-direction: column;
    gap: 12px;
  }
  
  .bookmarks-search .search-input {
    font-size: 16px; /* 防止iOS缩放 */
  }
  
  /* 触摸友好的按钮 */
  .bookmark-action {
    min-width: 44px;
    min-height: 44px;
    padding: 12px;
  }
  
  /* 右键菜单移动端适配 */
  .bookmark-context-menu {
    min-width: 200px;
    font-size: 16px;
  }
  
  .context-menu-item {
    padding: 12px 16px;
    min-height: 44px;
  }
}

@media (max-width: 1024px) and (min-width: 769px) {
  .bookmarks-panel.tablet-mode {
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  }
  
  .bookmarks-toolbar {
    padding: 16px 20px;
  }
  
  .bookmark-card {
    padding: 16px 20px;
  }
}

@media (max-width: 480px) {
  .bookmarks-toolbar {
    padding: 12px 16px;
  }
  
  .bookmark-card {
    padding: 12px 16px;
  }
  
  .bookmark-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .bookmark-title {
    font-size: 16px;
    line-height: 1.3;
  }
  
  .bookmark-preview {
    font-size: 14px;
    -webkit-line-clamp: 3;
  }
  
  /* 模态框移动端适配 */
  .modal-dialog {
    margin: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
  }
  
  .modal-content {
    border-radius: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  .modal-body {
    flex: 1;
    overflow-y: auto;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .bookmark-card {
    padding: 16px;
  }
  
  .bookmark-actions {
    opacity: 1;
    position: static;
    margin-top: 12px;
    justify-content: flex-end;
  }
  
  .bookmark-action {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    margin-left: 8px;
  }
  
  /* 禁用拖拽样式 */
  .bookmark-card[draggable="true"] {
    cursor: default;
  }
  
  .bookmark-card[draggable="true"]:hover {
    box-shadow: none;
  }
}

/* 暗色主题支持 */
[data-theme="dark"] .bookmarks-panel {
  background: #1f2937;
  border-color: #374151;
}

[data-theme="dark"] .bookmarks-header {
  background: #111827;
  border-color: #374151;
}

[data-theme="dark"] .bookmarks-header h3 {
  color: #f9fafb;
}

[data-theme="dark"] .bookmarks-toolbar {
  background: #1f2937;
  border-color: #374151;
}

[data-theme="dark"] .bookmarks-search .search-input {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

[data-theme="dark"] .bookmarks-search .search-input:focus {
  border-color: #3b82f6;
}

[data-theme="dark"] .bookmarks-filters select {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

[data-theme="dark"] .bookmark-card {
  border-color: #374151;
}

[data-theme="dark"] .bookmark-card:hover {
  background-color: #374151;
}

[data-theme="dark"] .bookmark-title {
  color: #f9fafb;
}

[data-theme="dark"] .bookmark-title:hover {
  color: #60a5fa;
}

[data-theme="dark"] .bookmark-meta {
  color: #9ca3af;
}

[data-theme="dark"] .bookmark-description {
  color: #d1d5db;
}

[data-theme="dark"] .bookmark-preview {
  color: #9ca3af;
}

[data-theme="dark"] .bookmark-tag {
  background: #4b5563;
  color: #e5e7eb;
}

[data-theme="dark"] .bookmark-footer {
  color: #6b7280;
}

[data-theme="dark"] .bookmarks-empty {
  color: #9ca3af;
}

[data-theme="dark"] .bookmarks-empty h4 {
  color: #d1d5db;
}

[data-theme="dark"] .bookmark-action:hover {
  background-color: #4b5563;
}

[data-theme="dark"] .content-preview {
  background: #374151;
  border-color: #4b5563;
  color: #9ca3af;
}