/* ============================================
   图片形状裁剪 - 样式表
   参考 scanner2 紫蓝渐变风格
   ============================================ */

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1b1b1b;
  background: linear-gradient(135deg, #f6f7fb 0%, #f0f4f9 100%);
  min-height: 100vh;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

a { text-decoration: none; color: inherit; }

/* ---- 顶部导航 ---- */
.topbar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 0;
}

.topbar .content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: white;
  font-weight: 600;
}

/* ---- 主容器 ---- */
#app {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 40px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- 上传区域 ---- */
.upload-section {
  width: 100%;
  max-width: 640px;
  margin: 24px 16px 16px 16px;
}

.file-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px;
  margin: 0 auto;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
  transition: all 0.3s ease;
  border: 2px dashed rgba(102, 126, 234, 0.4);
  cursor: pointer;
  min-height: 160px;
}

.file-selector:hover,
.file-selector.highlight {
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.file-selector-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1b1b1b;
}

.file-selector-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 16px;
}

.file-selector-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.file-selector-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-selector-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.file-selector-button.btn-secondary {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  border: 1px solid rgba(102, 126, 234, 0.3);
}

.file-selector-button.btn-secondary:hover {
  background: rgba(102, 126, 234, 0.15);
  color: #5a6bb8;
}

/* URL输入 */
.url-input-wrapper {
  margin-top: 12px;
  width: 100%;
}

.url-input-row {
  display: flex;
  gap: 8px;
}

.url-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.url-input:focus {
  border-color: #667eea;
}

.url-input::placeholder {
  color: #aaa;
}

.url-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.url-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.url-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ---- 编辑区域 ---- */
.editor-section {
  width: 100%;
  max-width: 900px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 形状选择面板 */
.shape-panel {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.shape-panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 12px;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.shape-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px 8px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(135deg, #f8f9fa, #fff);
}

.shape-item:hover {
  border-color: rgba(102, 126, 234, 0.3);
  background: linear-gradient(135deg, #f0f2ff, #fff);
}

.shape-item.active {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.05));
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.shape-item svg {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  transition: transform 0.2s;
}

.shape-item:hover svg,
.shape-item.active svg {
  transform: scale(1.1);
}

.shape-item .shape-name {
  font-size: 0.7rem;
  color: #666;
  font-weight: 500;
}

.shape-item.active .shape-name {
  color: #667eea;
  font-weight: 600;
}

/* 画布区域 */
.canvas-wrapper {
  position: relative;
  background: #f0f0f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  margin-bottom: 16px;
  max-width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.canvas-wrapper canvas {
  display: block;
  cursor: move;
}

/* 选项面板 */
.options-panel {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.option-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1b1b1b;
  white-space: nowrap;
}

.option-btns {
  display: flex;
  gap: 6px;
}

.option-btn {
  padding: 6px 14px;
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  background: #fff;
  color: #667eea;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.option-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
}

.option-btn:hover:not(.active) {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

.option-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.range-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e5e7eb;
  border-radius: 2px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.range-value {
  font-size: 0.75rem;
  color: #666;
  min-width: 28px;
}

.toggle-btn {
  padding: 6px 16px;
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  background: #fff;
  color: #667eea;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn[data-on="true"] {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
}

.toggle-btn:hover {
  border-color: #667eea;
}

/* 旋转按钮 */
.rotate-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  background: #fff;
  color: #667eea;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.rotate-btn:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

.rotate-btn:active {
  background: rgba(102, 126, 234, 0.1);
}

.rotation-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: #667eea;
  min-width: 32px;
  text-align: center;
}

/* 操作按钮 */
.action-buttons {
  width: 100%;
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.action-btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.action-btn.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.action-btn.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.action-btn.btn-secondary {
  background: #fff;
  color: #667eea;
  border: 2px solid rgba(102, 126, 234, 0.3);
}

.action-btn.btn-secondary:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

/* ---- 其它工具导航链接 ---- */
.navigation-links {
  max-width: 800px;
  width: 100%;
  margin: 0 auto 16px auto;
  padding: 0 16px;
}

.navigation-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 16px;
  text-align: center;
  padding-top: 24px;
  position: relative;
}

.navigation-section-title::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1px;
}

.navigation-links-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.navigation-link-item {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid rgba(102, 126, 234, 0.25);
  border-radius: 10px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.navigation-link-item:hover {
  border-color: #667eea;
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.navigation-link-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navigation-link-icon svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.navigation-link-item:hover .navigation-link-icon svg {
  transform: scale(1.1);
}

.navigation-link-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 4px;
  line-height: 1.2;
}

.navigation-link-subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 0;
  line-height: 1.2;
  display: inline-block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ---- 使用说明 ---- */
.howto-section {
  margin-top: 24px;
  padding: 20px 0;
  width: 100%;
  max-width: 640px;
}

.howto-section h2 {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 16px;
  position: relative;
  padding-top: 12px;
}

.howto-section h2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1px;
}

.howto-section p {
  font-size: 0.9rem;
  color: #4f4f4f;
  line-height: 1.7;
  margin-bottom: 10px;
}

.howto-list {
  list-style: none;
  counter-reset: step-counter;
  padding: 0;
}

.howto-list li {
  counter-increment: step-counter;
  position: relative;
  padding: 14px 14px 14px 52px;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  font-size: 14px;
  color: #4f4f4f;
  line-height: 1.5;
}

.howto-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.howto-list li strong,
.howto-list dt strong {
  color: #1b1b1b;
}

.howto-list dt {
  font-size: 14px;
  padding: 10px 14px 2px;
  margin-top: 6px;
  background: #fff;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.howto-list dd {
  font-size: 14px;
  color: #666;
  padding: 2px 14px 12px;
  margin: 0 0 2px;
  background: #fff;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(27, 27, 27, 0.9);
  color: #fff;
  padding: 12px 28px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: fadeInUp 0.3s ease;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.toast-error {
  background: rgba(239, 68, 68, 0.9);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- 响应式 ---- */
@media (max-width: 767px) {
  .file-selector {
    width: calc(100% - 32px);
    padding: 20px 12px;
  }

  .file-selector-title {
    font-size: 1.1rem;
  }

  .file-selector-subtitle {
    font-size: 0.8rem;
    margin-bottom: 14px;
  }

  .shape-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .shape-item {
    padding: 8px 2px 6px;
  }

  .shape-item svg {
    width: 24px;
    height: 24px;
  }

  .shape-item .shape-name {
    font-size: 0.65rem;
  }

  .options-panel {
    flex-direction: column;
    gap: 12px;
  }

  .option-row {
    width: 100%;
  }

  .range-slider {
    flex: 1;
    min-width: 60px;
  }

  .url-input-row {
    flex-direction: column;
  }

  .url-btn {
    width: 100%;
  }

  .editor-section {
    padding: 0 8px;
  }

  .navigation-links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .navigation-link-item {
    padding: 8px 4px;
    min-height: 50px;
  }

  .navigation-link-icon svg {
    width: 16px;
    height: 16px;
  }

  .navigation-link-title {
    font-size: 0.7rem;
  }

  .navigation-link-subtitle {
    font-size: 0.65rem;
    padding: 3px 6px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .shape-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .shape-item svg {
    width: 26px;
    height: 26px;
  }
}

@media (min-width: 769px) {
  .shape-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
  }

  .shape-item svg {
    width: 30px;
    height: 30px;
  }

  .navigation-links-grid {
    gap: 16px;
  }

  .navigation-link-item {
    padding: 16px 12px;
    min-height: 70px;
  }
}
