/* CSS Reset & Base */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.app-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header Simple */
.app-header-simple {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 32px;
}

.logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Upload Zone */
.upload-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone {
  width: 100%;
  max-width: 600px;
  background-color: var(--surface-color);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary-color);
  background-color: #eff6ff;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.upload-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

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

/* Workspace - Three Columns */
.workspace {
  flex: 1;
  display: flex;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background-color: var(--surface-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panel: Left List */
.panel-list {
  width: 240px;
  flex-shrink: 0;
}

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

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.image-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  /* 单列 */
  gap: 12px;
}

.image-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  background-color: #f1f5f9;
  aspect-ratio: auto;
  /* 自适应 */
}

.image-item img {
  width: 100%;
  display: block;
  object-fit: contain;
  /* 完整显示 */
  max-height: 300px;
}

.image-item.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.image-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
}

.image-item:hover .remove-btn {
  opacity: 1;
}

.feature-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: #fbbf24;
  color: #fff;
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 4px;
  display: none;
}

.image-item.is-feature .feature-badge {
  display: block;
}

.list-stat {
  padding: 8px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* Panel: Center Preview */
.panel-preview {
  flex: 1;
  background-color: #e2e8f0;
  /* 深色底 */
  padding: 24px;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-area {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas#previewCanvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  background: white;
}

.preview-placeholder {
  color: var(--text-secondary);
  text-align: center;
}

.preview-info-bar {
  position: absolute;
  bottom: 24px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  backdrop-filter: blur(4px);
}

/* Panel: Right Settings */
.panel-settings {
  width: 320px;
  flex-shrink: 0;
  padding: 0;
  /* Header padding handles top */
}

.settings-group {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.settings-group h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sync-control {
  margin-bottom: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.crop-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.crop-row label {
  width: 60px;
  font-size: 12px;
  color: var(--text-secondary);
}

.crop-row input[type="range"] {
  flex: 1;
}

.crop-input-group {
  width: 70px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.crop-input-group input {
  width: 100%;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: right;
  font-size: 12px;
}

.feature-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: center;
}

.output-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.info-item {
  background: #f8fafc;
  padding: 8px;
  border-radius: 6px;
  text-align: center;
}

.info-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.info-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-footer {
  padding: 16px;
  margin-top: auto;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

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

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

.btn-secondary:hover {
  background-color: #f1f5f9;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 8px;
}

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

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}

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

.modal {
  background: white;
  padding: 24px;
  border-radius: var(--radius-lg);
  width: 320px;
  text-align: center;
}

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  margin: 16px 0;
  overflow: hidden;
}

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