/* =========================================
   素材库 - 设计师素材管理系统
   ========================================= */

/* --- 颜色系统 --- */
:root {
  --primary: #534AB7;
  --primary-light: #EEEDFE;
  --primary-dark: #3C3489;
  --teal: #1D9E75;
  --teal-light: #E1F5EE;
  --coral: #D85A30;
  --coral-light: #FAECE7;
  --amber: #BA7517;
  --amber-light: #FAEEDA;
  --blue: #378ADD;
  --blue-light: #E6F1FB;

  --bg: #F5F5F7;
  --bg-white: #FFFFFF;
  --bg-hover: #F1F1F4;
  --border: #E5E5EA;
  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #A1A1A6;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* --- 全局重置 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.6;
}

/* SVG 图标统一样式 */
svg {
  flex-shrink: 0;
  vertical-align: middle;
}

/* --- 布局 --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- 侧边栏 --- */
.sidebar {
  width: 220px;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.sidebar-title {
  font-weight: 600;
  font-size: 15px;
}

.sidebar-nav {
  padding: 12px 12px;
  flex: 1;
}

.upload-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 16px;
}

.upload-btn:hover {
  background: var(--primary-dark);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.nav-section-title {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 16px 16px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.company-list {
  padding: 0 12px 16px;
  max-height: 320px;
  overflow-y: auto;
}

.company-list::-webkit-scrollbar {
  width: 3px;
}

.company-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* 企业分组（目录样式） */
.company-group {
  margin-bottom: 2px;
}

.company-group-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  padding: 8px 12px 4px;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  background: var(--bg-white);
  z-index: 1;
}

.company-groups {
  max-height: 320px;
  overflow-y: auto;
}

.company-groups::-webkit-scrollbar {
  width: 3px;
}

.company-groups::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.company-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.company-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.company-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.company-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* --- 主区域 --- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* --- 顶部栏 --- */
.topbar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  transition: border 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  background: var(--bg-white);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
}

/* --- 内容区 --- */
.content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

/* --- 统计卡片 --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- 筛选栏 --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-right: 4px;
}

.filter-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-white);
  cursor: pointer;
  outline: none;
}

.filter-select:focus {
  border-color: var(--primary);
}

.view-toggle {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.view-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.view-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* --- 素材网格 --- */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.asset-grid.list-view {
  grid-template-columns: 1fr;
}

.asset-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
  cursor: pointer;
}

.asset-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.asset-preview {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  position: relative;
  overflow: hidden;
}

.asset-type-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.9);
  color: var(--text-secondary);
}

/* 收藏按钮 */
.fav-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  opacity: 0;
}

.asset-card:hover .fav-btn {
  opacity: 1;
}

.fav-btn:hover {
  transform: scale(1.15);
}

/* 卡片缩略图 */
.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.asset-card:hover .card-thumb {
  transform: scale(1.05);
}

.asset-info {
  padding: 12px 14px;
}

.asset-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-tertiary);
}

.asset-tags {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.asset-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* --- 配色展示 --- */
.asset-colors {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 0.5px solid var(--border);
}

/* --- 列表视图样式 --- */
.list-view .asset-card {
  display: flex;
  height: 72px;
}

.list-view .asset-preview {
  width: 100px;
  height: 100%;
  flex-shrink: 0;
  font-size: 24px;
}

.list-view .asset-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
}

.list-view .asset-name {
  width: 200px;
  margin-bottom: 0;
}

.list-view .asset-meta {
  gap: 20px;
  flex: 1;
}

.list-view .asset-tags {
  margin-top: 0;
}

/* --- 上传弹窗 --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 500px;
  max-width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 20px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-hover);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.modal-body {
  padding: 20px 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-white);
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.drop-zone-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.drop-zone-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-white);
  color: var(--text-primary);
}

.btn:hover {
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

/* --- 空状态 --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

/* --- Toast 通知 --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
}

.toast {
  padding: 12px 20px;
  background: var(--text-primary);
  color: white;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-top: 8px;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- 预览弹窗 --- */
.preview-modal {
  width: 420px;
}

.preview-hero {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.preview-detail {
  margin-bottom: 16px;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.preview-row:last-child {
  border-bottom: none;
}

.preview-label {
  color: var(--text-secondary);
}

.preview-value {
  font-weight: 500;
}

.preview-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- 危险按钮（删除） --- */
.btn-danger {
  background: transparent;
  color: #E53935;
  border-color: #FFCDD2;
  margin-right: auto;
}

.btn-danger:hover {
  background: #FFEBEE;
}

/* --- 统计面板 --- */
.stats-view {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.stats-view-header {
  margin-bottom: 20px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg, 12px);
  padding: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* --- 深色模式 --- */
body.dark-mode {
  --bg: #1C1C1E;
  --bg-white: #2C2C2E;
  --bg-hover: #3A3A3C;
  --border: #48484A;
  --text-primary: #F5F5F7;
  --text-secondary: #AEAEB2;
  --text-tertiary: #636366;
  --shadow: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.3);
  --primary-light: #3C3489;
}

body.dark-mode .sidebar {
  border-right-color: var(--border);
}

body.dark-mode .topbar {
  border-bottom-color: var(--border);
}

body.dark-mode .search-input {
  background: var(--bg-hover);
  border-color: var(--border);
}

body.dark-mode .stat-card,
body.dark-mode .asset-card,
body.dark-mode .chart-card {
  background: var(--bg-white);
  border-color: var(--border);
}

body.dark-mode .filter-select {
  background: var(--bg-white);
  color: var(--text-primary);
  border-color: var(--border);
}

body.dark-mode .modal {
  background: var(--bg-white);
}

body.dark-mode .form-input,
body.dark-mode .form-select {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

body.dark-mode .upload-btn {
  background: #7C4DFF;
}
