/* Kujiale 插件主样式 */
:root {
  --primary: #667eea;
  --primary-dark: #5a6fd6;
  --primary-light: #eef1fd;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --border: #e0e0e0;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --sidebar-width: 220px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC',
    Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ---------- 整体布局 ---------- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: #1a1a2e;
  color: #d5d7e3;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 20px 16px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo span {
  color: var(--primary);
}

.logo-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  border-left: 3px solid transparent;
  color: inherit;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  background: rgba(102, 126, 234, 0.2);
  color: #fff;
  border-left-color: var(--primary);
}

.nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  text-align: center;
  font-size: 16px;
}

.nav-item .nav-text {
  font-size: 13px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #8a8ca0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lang-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 4px 14px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ---------- 页面标题 ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* ---------- 资源卡片（产品/案例/户型图） ---------- */
.resource-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
}

.resource-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.resource-card.draggable {
  cursor: grab;
}

.resource-card.draggable:active {
  cursor: grabbing;
}

.resource-card .thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: linear-gradient(135deg, #eef1ff 0%, #e4eafc 100%);
  display: block;
  transition: transform 0.35s ease, filter 0.35s ease;
  cursor: pointer;
}

.resource-card:hover .thumb {
  transform: scale(1.05);
  filter: brightness(1.02);
}

.resource-card .thumb-placeholder {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef1ff 0%, #e4eafc 100%);
  color: var(--primary);
  font-size: 36px;
}

.resource-card .info {
  padding: 12px;
}

.resource-card .info .name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-card .info .sub {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.resource-card .info .price {
  font-weight: 700;
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

.resource-card .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
}

.resource-card .actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: #ecf0f1;
  color: var(--text);
}

.btn-secondary:hover {
  background: #dfe6e9;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

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

/* ---------- 表单 ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-label .req {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

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

.form-textarea {
  min-height: 60px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
}

.form-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* 复选框组 */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  background: #fff;
}

.checkbox-tag input {
  display: none;
}

.checkbox-tag.checked {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.checkbox-tag:hover {
  border-color: var(--primary);
}

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

.filter-bar .form-select,
.filter-bar .form-input {
  width: auto;
  min-width: 120px;
}

/* ---------- 统计卡片 ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ---------- 排行榜 ---------- */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.leaderboard-table th {
  background: var(--primary-light);
  font-weight: 600;
  color: var(--text);
  position: sticky;
  top: 0;
}

.leaderboard-table tr:hover td {
  background: #fafafa;
}

.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
}

.rank-1 {
  background: #f39c12;
  color: #fff;
}

.rank-2 {
  background: #95a5a6;
  color: #fff;
}

.rank-3 {
  background: #cd7f32;
  color: #fff;
}

.rank-other {
  background: #ecf0f1;
  color: var(--text);
}

.total-count {
  font-weight: 700;
  color: var(--primary);
  font-size: 15px;
}

.breakdown {
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  gap: 10px;
}

.breakdown span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.breakdown strong {
  color: var(--text);
}

.member-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  border: 2px solid #fff;
}

.tag-select-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tag-select-row .form-select {
  flex: 1;
}

/* ---------- 标签 / 徽章 ---------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  font-size: 11px;
  margin-right: 4px;
  white-space: nowrap;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.role-admin {
  background: #fbeaea;
  color: var(--danger);
}

.role-designer {
  background: var(--primary-light);
  color: var(--primary);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.status-active {
  background: #eafaf1;
  color: var(--success);
}

.status-disabled {
  background: #f8f9fa;
  color: var(--text-light);
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 大图查看 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 4px;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.25s;
  max-width: 320px;
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast-info {
  background: var(--primary);
}

.toast-warning {
  background: var(--warning);
}

/* ---------- 加载与空态 ---------- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-light);
  font-size: 13px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #eef1ff 0%, #e8ecfa 100%);
  border: 1px solid rgba(102, 126, 234, 0.2);
  box-shadow: inset 0 2px 6px rgba(102, 126, 234, 0.06);
  color: var(--primary);
  opacity: 0.85;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-svg {
  display: block;
}

.empty-state .empty-text {
  font-size: 13px;
  letter-spacing: 0.2px;
}

/* ---------- 纹理网格 ---------- */
.texture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.texture-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.texture-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.texture-item img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.texture-item .texture-info {
  padding: 8px;
  font-size: 11px;
  text-align: center;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.texture-item .texture-info .cat {
  color: var(--text-light);
  font-size: 10px;
}

/* ---------- BOQ 表格 ---------- */
.boq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.boq-table th,
.boq-table td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.boq-table th {
  background: var(--primary-light);
  font-weight: 600;
}

.boq-table .num {
  text-align: right;
}

.boq-grand-total {
  text-align: right;
  font-size: 16px;
  font-weight: 700;
  color: var(--danger);
  margin-top: 16px;
}

/* ---------- 用户管理表格 ---------- */
.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.user-table th,
.user-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.user-table th {
  background: var(--primary-light);
  font-weight: 600;
}

/* ---------- 页签 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-light);
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ---------- 首页快捷操作 ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.quick-action {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  color: var(--text);
}

.quick-action:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.quick-action .qa-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.quick-action .qa-label {
  font-size: 13px;
  font-weight: 500;
}

/* ---------- 上传拖放区 ---------- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

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

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

.confirm-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff3f3 0%, #ffe8e8 100%);
  border: 1px solid rgba(229, 72, 77, 0.25);
  color: #e5484d;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.pagination .page-info {
  font-size: 13px;
  color: var(--text-light);
}

/* ---------- 拖拽元素 ---------- */
.drag-overlay {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.85;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  max-width: 180px;
}

/* ---------- 动画 ---------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar {
    width: 64px;
  }

  .nav-item .nav-text {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 11px 0;
  }

  .sidebar-logo {
    justify-content: center;
    font-size: 16px;
    padding: 16px 8px;
  }

  .sidebar-logo span {
    display: none;
  }

  .sidebar-footer {
    justify-content: center;
  }

  .lang-toggle {
    font-size: 10px;
    padding: 3px 10px;
  }

  .main {
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}