/* 图片工具页面公用样式 */

/* 页面容器 */
.image-tools-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 2rem 0;
}

/* 工具卡片 */
.tool-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 2rem;
  transition: all 0.3s ease;
  height: 100%;
}

.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px rgba(31, 38, 135, 0.45);
}

/* 工具标题 */
.tool-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 1.5rem;
  text-align: center;
  position: relative;
  padding-bottom: 0.5rem;
}

.tool-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px;
}

/* 图片上传区域 */
.image-upload-area {
  border: 2px dashed #ddd;
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: rgba(248, 249, 250, 0.8);
}

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

.image-upload-area input[type="file"] {
  display: none;
}

.upload-icon {
  font-size: 3rem;
  color: #667eea;
  margin-bottom: 1rem;
}

.upload-text {
  font-size: 1rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.upload-hint {
  font-size: 0.875rem;
  color: #999;
}

/* 图片预览区域 */
.image-preview {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  margin: 1.5rem 0;
  background-color: #f8f9fa;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
}

/* 操作按钮 */
.action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn-primary {
  background: linear-gradient(90deg, #667eea, #764ba2);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background-color: #f8f9fa;
  color: #333;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background-color: #e9ecef;
  transform: translateY(-2px);
}

/* 控制面板 */
.control-panel {
  background-color: rgba(248, 249, 250, 0.8);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.control-group {
  margin-bottom: 1.25rem;
}

.control-label {
  display: block;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.control-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: all 0.3s ease;
}

.control-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 滑块控件 */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
  transition: all 0.3s ease;
}

.slider:hover {
  background: #ccc;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  cursor: pointer;
  transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
}

.slider::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* 选择器 */
.select-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.875rem;
  background-color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.select-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 分割线 */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #ddd, transparent);
  margin: 2rem 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .image-tools-container {
    padding: 1rem 0;
  }

  .tool-card {
    padding: 1.5rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .image-upload-area {
    padding: 1.5rem;
  }
}

/* 加载动画 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  border-top-color: #667eea;
  animation: spin 1s ease-in-out infinite;
}

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

/* 错误提示 */
.error-message {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* 成功提示 */
.success-message {
  color: #28a745;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* ============================================
   布局优化：上传后收起上传区，改为左图右控双栏，
   减少上下滚动、方便原图与结果对比
   ============================================ */

/* 已选文件时的紧凑提示条 */
.file-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #10b981;
  font-weight: 600;
  font-size: 0.95rem;
}

.file-bar .file-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.btn-change {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(102, 126, 234, 0.4);
  background: #fff;
  color: #667eea;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-change:hover {
  background: #667eea;
  color: #fff;
}

/* 双栏工作区：左列图片（吸顶），右列控制项 */
.tool-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.workspace-preview {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.workspace-preview .image-preview {
  margin: 0;
}

/* 预览列内的图片统一限制高度，避免撑高页面 */
.workspace-preview img {
  max-height: 46vh;
}

/* 分割结果用的是按像素定位的小图，不限制高度 */
.workspace-preview .piece-container img {
  max-height: none;
}

.workspace-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.workspace-controls .tool-options {
  margin: 0;
}

.workspace-controls .action-buttons {
  margin-top: 0;
}

/* 结果为空时的占位提示 */
.results-empty {
  text-align: center;
  padding: 48px 20px;
  color: #94a3b8;
  background: #f8fafc;
  border: 1px dashed rgba(102, 126, 234, 0.25);
  border-radius: 12px;
}

.results-empty i {
  display: block;
  font-size: 2.4rem;
  color: #a5b4fc;
  margin-bottom: 12px;
}

.results-empty p {
  margin: 0;
  font-size: 0.9rem;
}

.workspace-preview .results-area {
  margin-top: 0;
}

@media (max-width: 900px) {
  .tool-workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .workspace-preview {
    position: static;
  }

  .workspace-preview img {
    max-height: none;
  }
}