/* =========================================
   FILE MANAGER PANEL (文件管理)
   ========================================= */

/* Panel — overlays main content area, preserves left icon sidebar */
.fm-panel {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f8f9fb;
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: fmSlideIn 0.25s ease;
}
@keyframes fmSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Header ---- */
.fm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 0;
  flex-shrink: 0;
}
.fm-header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.fm-title {
  font-size: 20px;
  font-weight: 600;
  color: rgba(0,0,0,0.85);
}
.fm-file-count {
  font-size: 13px;
  color: rgba(0,0,0,0.4);
}
.fm-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search */
.fm-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  width: 240px;
  transition: border-color 0.2s;
}
.fm-search-wrap:focus-within { border-color: #276ff5; }
.fm-search-wrap svg { width: 15px; height: 15px; color: rgba(0,0,0,0.3); flex-shrink: 0; }
.fm-search {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: rgba(0,0,0,0.82);
  font-family: inherit;
}
.fm-search::placeholder { color: rgba(0,0,0,0.3); }

/* View toggle */
.fm-view-toggle {
  display: flex;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  overflow: hidden;
}
.fm-view-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
}
.fm-view-btn svg { width: 15px; height: 15px; color: rgba(0,0,0,0.4); }
.fm-view-btn:hover { background: #f5f5f5; }
.fm-view-btn.active { background: #276ff5; }
.fm-view-btn.active svg { color: #fff; }

/* Close button */
.fm-close-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.fm-close-btn:hover { background: rgba(0,0,0,0.06); }
.fm-close-btn svg { width: 15px; height: 15px; color: rgba(0,0,0,0.5); }

/* ---- Category Tabs ---- */
.fm-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 28px 0;
  flex-shrink: 0;
}
.fm-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: 13px;
  color: rgba(0,0,0,0.55);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.fm-tab svg { width: 14px; height: 14px; }
.fm-tab:hover { background: rgba(0,0,0,0.04); color: rgba(0,0,0,0.75); }
.fm-tab.active {
  background: #276ff5;
  color: #fff;
}
.fm-tab.active svg { stroke: #fff; }

/* ---- Content area ---- */
.fm-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 28px;
}

/* ---- Grid View ---- */
.fm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.fm-grid.list-view {
  grid-template-columns: 1fr;
  gap: 4px;
}

/* ---- File Card (Grid View) ---- */
.fm-file-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #eee;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.fm-file-card:hover {
  border-color: #d0d8e8;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}
.fm-file-card .fm-card-thumb {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.fm-card-thumb-icon {
  font-size: 40px;
  opacity: 0.9;
}
.fm-card-type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.fm-card-body {
  padding: 12px 14px 14px;
}
.fm-card-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(0,0,0,0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.fm-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(0,0,0,0.38);
}
.fm-card-source {
  display: flex;
  align-items: center;
  gap: 4px;
}
.fm-card-source-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fm-card-actions {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.fm-file-card:hover .fm-card-actions { opacity: 1; }
.fm-card-action-btn {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.fm-card-action-btn:hover { background: #fff; }
.fm-card-action-btn svg { width: 14px; height: 14px; color: rgba(0,0,0,0.55); }


/* ---- File Card (List View) ---- */
.fm-grid.list-view .fm-file-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  border-radius: 10px;
  padding: 10px 16px;
}
.fm-grid.list-view .fm-file-card:hover {
  transform: none;
}
.fm-grid.list-view .fm-card-thumb {
  width: 40px; height: 40px;
  min-width: 40px;
  border-radius: 8px;
}
.fm-grid.list-view .fm-card-thumb-icon { font-size: 20px; }
.fm-grid.list-view .fm-card-type-badge { display: none; }
.fm-grid.list-view .fm-card-body {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 0 0 14px;
  gap: 16px;
}
.fm-grid.list-view .fm-card-name {
  flex: 1;
  margin-bottom: 0;
  font-size: 13px;
}
.fm-grid.list-view .fm-card-meta {
  gap: 24px;
  flex-shrink: 0;
}
.fm-grid.list-view .fm-card-actions {
  position: static;
  opacity: 0;
  margin-left: 8px;
}

/* ---- Type-specific colors ---- */
.fm-type-markdown .fm-card-thumb { background: linear-gradient(135deg, #f0f4ff, #e8eeff); }
.fm-type-markdown .fm-card-type-badge { background: #e8eeff; color: #3b6ce7; }

.fm-type-document .fm-card-thumb { background: linear-gradient(135deg, #fff5f0, #ffe8db); }
.fm-type-document .fm-card-type-badge { background: #ffe8db; color: #d35400; }

.fm-type-spreadsheet .fm-card-thumb { background: linear-gradient(135deg, #f0faf4, #ddf5e6); }
.fm-type-spreadsheet .fm-card-type-badge { background: #ddf5e6; color: #16a34a; }

.fm-type-code .fm-card-thumb { background: linear-gradient(135deg, #f5f0ff, #ece4ff); }
.fm-type-code .fm-card-type-badge { background: #ece4ff; color: #7c3aed; }

.fm-type-image .fm-card-thumb { background: linear-gradient(135deg, #fef5f0, #fde8e0); }
.fm-type-image .fm-card-type-badge { background: #fde8e0; color: #db2777; }

/* ---- Preview Modal ---- */
.fm-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fmFadeIn 0.2s ease;
}
@keyframes fmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.fm-preview-modal {
  width: 680px;
  max-width: 90vw;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: fmScaleIn 0.25s ease;
}
@keyframes fmScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.fm-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
}
.fm-preview-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fm-preview-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.fm-preview-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.fm-preview-btn:hover { background: rgba(0,0,0,0.06); }
.fm-preview-btn svg { width: 16px; height: 16px; color: rgba(0,0,0,0.5); }
.fm-preview-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: rgba(0,0,0,0.4);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  margin-left: 4px;
}
.fm-preview-close:hover { background: rgba(0,0,0,0.06); }
.fm-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(0,0,0,0.72);
}
.fm-preview-body pre {
  background: #f6f8fa;
  border-radius: 8px;
  padding: 16px;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.fm-preview-body .fm-preview-image {
  max-width: 100%;
  border-radius: 8px;
}
.fm-preview-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fm-preview-body table th,
.fm-preview-body table td {
  padding: 8px 12px;
  border: 1px solid #eee;
  text-align: left;
}
.fm-preview-body table th {
  background: #f8f9fb;
  font-weight: 600;
  color: rgba(0,0,0,0.65);
}
.fm-preview-footer {
  padding: 12px 20px;
  border-top: 1px solid #f0f0f0;
  font-size: 12px;
  color: rgba(0,0,0,0.38);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- Empty state ---- */
.fm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: rgba(0,0,0,0.3);
}
.fm-empty-icon { font-size: 48px; margin-bottom: 12px; }
.fm-empty-text { font-size: 14px; }

/* ---- Nav icon active state ---- */
.nav-icon.active {
  opacity: 1;
  color: #276ff5;
}


/* =========================================
   SECTION TABS (文件管理 / 历史记录 顶级切换)
   ========================================= */
.fm-section-tabs {
  display: flex;
  gap: 0;
  flex-shrink: 0;
}
.fm-section-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  color: rgba(0,0,0,0.35);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  user-select: none;
}
.fm-section-tab svg { width: 16px; height: 16px; }
.fm-section-tab:hover { color: rgba(0,0,0,0.65); }
.fm-section-tab.active {
  color: rgba(0,0,0,0.85);
}
.fm-section-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: #276ff5;
  border-radius: 2px 2px 0 0;
}
.fm-section-tab.active svg { stroke: #276ff5; }

/* File count inline in tab */
.fm-file-count-inline {
  font-size: 12px;
  font-weight: 400;
  color: rgba(0,0,0,0.35);
  margin-left: 2px;
}

/* Section containers */
.fm-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================
   HISTORY TABS (浏览记录 / 传输记录)
   ========================================= */
.fm-history-tabs {
  display: flex;
  gap: 0;
  padding: 0 28px;
  flex-shrink: 0;
  margin-top: 12px;
  background: #f0f2f5;
  border-radius: 10px;
  margin-left: 28px;
  margin-right: 28px;
  padding: 4px;
}
.fm-history-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(0,0,0,0.5);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  user-select: none;
}
.fm-history-tab svg { width: 15px; height: 15px; }
.fm-history-tab:hover { color: rgba(0,0,0,0.75); }
.fm-history-tab.active {
  background: #fff;
  color: rgba(0,0,0,0.85);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* History section content */
.fm-history-section {
  flex: 1;
  overflow-y: auto;
  padding: 0 28px 28px;
}
.fm-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
}
.fm-history-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(0,0,0,0.82);
}
.fm-history-clear {
  font-size: 13px;
  color: rgba(0,0,0,0.4);
  cursor: pointer;
  transition: color 0.15s;
}
.fm-history-clear:hover { color: #e74c3c; }

/* History list */
.fm-history-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Date group */
.fm-history-date {
  font-size: 13px;
  color: rgba(0,0,0,0.4);
  padding: 16px 0 8px;
  font-weight: 500;
}

/* History item */
.fm-history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.fm-history-item:hover { background: rgba(0,0,0,0.03); }

.fm-history-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}
.fm-history-icon.type-image { background: linear-gradient(135deg, #e0f5ee, #c8edd8); }
.fm-history-icon.type-document { background: linear-gradient(135deg, #e0f5ee, #c8edd8); }
.fm-history-icon.type-markdown { background: linear-gradient(135deg, #e8eeff, #d8e2ff); }
.fm-history-icon.type-spreadsheet { background: linear-gradient(135deg, #e0f5ee, #c8edd8); }
.fm-history-icon.type-code { background: linear-gradient(135deg, #f5f0ff, #ece4ff); }

.fm-history-icon svg {
  width: 22px;
  height: 22px;
  color: rgba(0,0,0,0.35);
}

.fm-history-info {
  flex: 1;
  min-width: 0;
}
.fm-history-name {
  font-size: 14px;
  font-weight: 500;
  color: rgba(0,0,0,0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.fm-history-meta {
  font-size: 12px;
  color: rgba(0,0,0,0.38);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fm-history-status {
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}
.fm-history-status.success { color: #16a34a; }
.fm-history-status.pending { color: #f59e0b; }
.fm-history-status.failed { color: #e74c3c; }

/* Empty state for history */
.fm-history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: rgba(0,0,0,0.25);
}
.fm-history-empty-icon { font-size: 48px; margin-bottom: 12px; }
.fm-history-empty-text { font-size: 14px; }
