/* 图片处理百宝箱 - 样式文件 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #1e293b;
  line-height: 1.6;
}

.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px;
}

header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #111;
}

header .subtitle {
  color: #64748b;
  font-size: 14px;
  margin-top: 6px;
}

.main-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  padding: 24px;
}

/* Tab Bar */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 15px;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: #334155; }
.tab-btn.active { color: #6366f1; border-bottom-color: #6366f1; font-weight: 600; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: #6366f1;
  background: #eef2ff;
}

.upload-icon {
  font-size: 48px;
  color: #94a3b8;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 16px;
  color: #475569;
}

.upload-hint {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 6px;
}

/* Workspace */
.workspace { display: none; }
.workspace.visible { display: block; }

.workspace-inner {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
}

.preview-area {
  background: #f8fafc;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

.preview-area canvas {
  max-width: 100%;
  max-height: 500px;
  display: block;
}

/* Controls Panel */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.control-group select,
.control-group input[type="text"],
.control-group input[type="number"],
.control-group input[type="color"] {
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
  width: 100%;
}

.control-group select:focus,
.control-group input:focus {
  border-color: #6366f1;
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: #6366f1;
}

.control-group input[type="checkbox"] {
  accent-color: #6366f1;
}

.btn-primary {
  padding: 10px 16px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: #4f46e5; }

.btn-secondary {
  padding: 8px 14px;
  background: #f1f5f9;
  color: #475569;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-secondary.active {
  background: #eef2ff;
  border-color: #6366f1;
  color: #6366f1;
}

.size-info {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  color: #64748b;
}

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

.size-info .row .value { font-weight: 600; color: #334155; }
.size-info .row .reduction { color: #22c55e; font-weight: 600; }

.download-bar {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

.download-bar .btn-primary {
  flex: 1;
  padding: 14px;
  font-size: 16px;
}

.tip-bar {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: #94a3b8;
}

/* Crop overlay */
.crop-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  cursor: crosshair;
  display: none;
  z-index: 10;
}

.crop-overlay.active { display: block; }

.crop-selection {
  position: absolute;
  border: 2px dashed #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

/* Position grid for watermark */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.position-grid .pos-btn {
  padding: 8px;
  border: 2px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.position-grid .pos-btn.active {
  background: #eef2ff;
  border-color: #6366f1;
  color: #6366f1;
}

/* Ad container */
#ad-container {
  margin-top: 24px;
  border-radius: 12px;
}

/* Hint text */
.hint-text {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 8px;
}

.hint-text-small {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Ratio buttons container */
.ratio-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 24px;
  padding: 16px;
  color: #94a3b8;
  font-size: 12px;
}

.app-footer .footer-links {
  margin-top: 4px;
}

/* Screen-reader only：对辅助技术和搜索引擎可见，视觉隐藏 */
.seo-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #22c55e;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* Loading overlay */
#loadingOverlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: #475569;
}

/* Mobile */
@media (max-width: 768px) {
  .app-container { padding: 16px 12px; }
  .main-card { padding: 16px; }
  header h1 { font-size: 22px; }
  .tab-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 8px 14px; font-size: 14px; }
  .workspace-inner { grid-template-columns: 1fr; }
  .preview-area { min-height: 180px; }
  .preview-area canvas { max-height: 300px; }
  .download-bar { flex-direction: column; }
}

@media (max-width: 480px) {
  .main-card { padding: 12px; border-radius: 10px; }
  .upload-zone { padding: 32px 16px; }
  .upload-icon { font-size: 36px; }
  .upload-text { font-size: 14px; }
}