/* ============================================
   素材库 (Material Library) 样式
   依赖: style.css (全局变量与基础组件)
   ============================================ */

/* ====== 页面容器 ====== */
.material-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ====== 顶部 Tab 栏 ====== */
.material-tabs {
  display: flex;
  gap: 0;
  padding: 16px 24px 0;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}
.material-tab {
  padding: 10px 24px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  user-select: none;
}
.material-tab:hover { color: #c49a6c; }
.material-tab.active {
  color: #c49a6c;
  border-bottom-color: #c49a6c;
  font-weight: 600;
}

/* ====== 主体：左侧分组 + 右侧内容 ====== */
.material-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ====== 左侧分组面板 ====== */
.material-sidebar {
  width: 170px;
  min-width: 170px;
  background: #fafafa;
  border-right: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.material-sidebar-header {
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}
.material-group-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.material-group-tree::-webkit-scrollbar { width: 4px; }
.material-group-tree::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 2px; }

/* ====== 左侧分组树 ====== */
/* 节点容器 */
.material-group-node {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 8px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  transition: background 0.15s;
  border-left: 3px solid transparent;
  position: relative;
}
.material-group-node:hover { background: #f0f0f0; }
.material-group-node.is-active {
  background: #f0d5d8;
  color: #c49a6c;
  border-left-color: #c49a6c;
  font-weight: 500;
}

/* 箭头占位（统一宽度，保证名称对齐） */
.material-group-arrow,
.material-group-arrow-placeholder {
  width: 14px;
  flex-shrink: 0;
  text-align: center;
  font-size: 10px;
  color: #999;
}
.material-group-arrow {
  cursor: pointer;
  transition: transform 0.2s;
}
.material-group-arrow:hover { color: #333; }
.material-group-arrow.expanded { transform: rotate(90deg); }
.material-group-arrow-placeholder { visibility: hidden; }

/* 文件夹图标 */
.material-group-folder {
  font-size: 14px;
  flex-shrink: 0;
}

/* 名称 — 长文本省略号 */
.material-group-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 操作图标容器 — 默认隐藏，hover 节点时显示 */
.material-group-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  visibility: hidden;
}
.material-group-node:hover .material-group-actions {
  visibility: visible;
}

/* 单个操作图标 */
.material-group-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  color: #999;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.material-group-action:hover { background: rgba(0,0,0,0.05); }
.material-group-action--add:hover  { color: #1890ff; }
.material-group-action--edit:hover { color: #1890ff; }
.material-group-action--delete:hover { color: #ef4444; }

/* 子节点容器 */
.material-group-children { /* display 由 JS 控制 */ }

/* "全部" 节点不显示操作图标（已通过 visibility:hidden + 空内容处理） */

.material-sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid #f0f0f0;
}

/* ====== 右侧内容区 ====== */
.material-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* ====== 工具栏 ====== */
.material-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.material-search {
  position: relative;
  width: 220px;
  flex-shrink: 0;
}
.material-search input {
  width: 100%;
  height: 34px;
  padding: 0 36px 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.material-search input:focus { border-color: #c49a6c; }
.material-search-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 15px;
  color: #999;
}
.material-search-icon:hover { color: #c49a6c; }

.material-toolbar-center {
  display: flex;
  gap: 6px;
}

.material-toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.material-sort-toggle {
  font-size: 12px;
  color: #999;
  cursor: pointer;
  user-select: none;
}
.material-sort-toggle:hover { color: #c49a6c; }
.material-type-hint {
  font-size: 12px;
  color: #bbb;
  white-space: nowrap;
}

/* ====== 表格 ====== */
.material-table-wrap {
  flex: 1;
  overflow: auto;
}
.material-table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.material-table-wrap::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 3px; }

.material-table { width: 100%; }
.material-table thead { position: sticky; top: 0; z-index: 2; }
.material-table th {
  background: #fafafa;
  font-weight: 600;
  font-size: 12px;
  color: #888;
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
}
.material-table td {
  padding: 10px 14px;
  font-size: 13px;
  color: #555;
  border-bottom: 1px solid #f5f5f5;
  vertical-align: middle;
}
.material-table tbody tr:hover td { background: #fef9f0; }
.material-table tbody tr.selected td { background: #faf3e8; }

/* 素材信息单元格 */
.material-info-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.material-thumb {
  flex-shrink: 0;
  background: #f5f5f5;
}
.material-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  margin-bottom: 2px;
  word-break: break-all;
}
.material-sub {
  font-size: 12px;
  color: #999;
}

/* 操作按钮 */
.material-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.material-action-sep {
  color: #e0e0e0;
  font-size: 12px;
}

/* ====== 底部工具栏 ====== */
.material-footer {
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
  padding: 10px 20px;
  flex-shrink: 0;
}
.material-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.material-footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.material-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.material-page-input {
  width: 50px;
  height: 32px;
  text-align: center;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.material-page-input:focus { border-color: #c49a6c; }

/* ====== 移动弹窗树 ====== */
.material-move-tree {
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  padding: 8px;
  background: #fafafa;
}
.material-move-item {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #555;
  transition: all 0.15s;
}
.material-move-item:hover { background: #f0d5d8; color: #c49a6c; }

/* ====== 响应式 ====== */
@media (max-width: 1100px) {
  .material-sidebar { width: 140px; min-width: 140px; }
  .material-toolbar { flex-wrap: wrap; }
  .material-toolbar-right { margin-left: 0; flex-wrap: wrap; }
}
