/* ===== 全局变量 & 重置 ===== */
:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --danger: #ff4d4f;
  --danger-hover: #ff7875;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1f1f1f;
  --text-secondary: #666;
  --border: #e8e8e8;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo { font-size: 24px; }

.title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

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

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

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

.btn-tool {
  background: #fff;
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 16px;
}
.btn-tool:hover { background: var(--bg); }
.btn-tool.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
}
.btn-close:hover { color: var(--text); }

/* ===== Pages ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== Model List ===== */
.stats-bar {
  padding: 16px 24px;
  color: var(--text-secondary);
  font-size: 14px;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 0 24px 24px;
}

.model-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
}
.model-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.model-thumb {
  height: 180px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: rgba(255,255,255,0.8);
  position: relative;
}

.model-thumb .format-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  text-transform: uppercase;
}

.model-info {
  padding: 14px;
}

.model-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.model-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.model-actions .btn {
  flex: 1;
  justify-content: center;
  padding: 6px 10px;
  font-size: 13px;
}

/* ===== Empty State ===== */
.empty-state {
  display: none;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}
.empty-state.visible { display: block; }

.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state p { margin-bottom: 8px; }
.empty-hint { font-size: 13px; color: #999; }

/* ===== Viewer Page ===== */
.viewer-toolbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-title {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.viewer-tools {
  display: flex;
  gap: 6px;
}

.viewer-container {
  display: flex;
  height: calc(100vh - 56px - 49px);
  position: relative;
}

.viewer-3d {
  flex: 1;
  background: #1a1a2e;
  position: relative;
}

.panel-properties {
  width: 300px;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  overflow: hidden;
}
.panel-properties.collapsed {
  width: 0;
  border: none;
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
}

.properties-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  font-size: 13px;
}

.properties-content .hint {
  color: var(--text-secondary);
  text-align: center;
  padding: 40px 0;
}

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

.prop-group-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.prop-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}

.prop-key { color: var(--text-secondary); }
.prop-val { color: var(--text); font-weight: 500; text-align: right; max-width: 60%; word-break: break-all; }

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26,26,46,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  color: #fff;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.modal-sm { width: 380px; }

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

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

.modal-body {
  padding: 20px;
}

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

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(22,119,255,0.04);
}

.drop-icon { font-size: 36px; margin-bottom: 10px; }
.drop-zone p { margin-bottom: 4px; color: var(--text-secondary); }
.drop-hint { font-size: 12px; color: #999; }

.file-info {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-name { font-weight: 500; font-size: 14px; }
.file-size { font-size: 12px; color: var(--text-secondary); }

.upload-progress {
  margin-top: 12px;
}

.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

#progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
}

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

.toast {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  min-width: 240px;
}

.toast.success { border-left: 3px solid #52c41a; }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .model-grid {
    grid-template-columns: 1fr;
  }
  .panel-properties {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
    box-shadow: var(--shadow-lg);
  }
  .viewer-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
