/* ===== Image Tools Mode ===== */

#imageToolsContainer {
  flex-direction: column;
  overflow: hidden;
}

.image-tools-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.image-tools-tab {
  padding: 6px 16px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.image-tools-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.image-tools-tab.active {
  background: var(--accent-blue-bg);
  border-color: var(--accent-blue);
  color: #fff;
}

.image-tools-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.image-tools-panel.hidden {
  display: none;
}

.image-tools-body {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.image-tools-upload,
.image-tools-options {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.image-tools-upload-row {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.image-tools-btn {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

.image-tools-btn:hover {
  border-color: var(--accent-blue);
}

.image-tools-btn.danger:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.image-tools-primary-btn {
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid var(--button-primary);
  background: var(--button-primary);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  align-self: flex-start;
}

.image-tools-primary-btn:hover {
  background: var(--button-primary-hover);
}

.image-tools-primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.image-tools-upload-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 2px dashed var(--border-light);
  border-radius: 8px;
  padding: 8px;
  background: var(--bg-primary);
  transition: all 0.15s;
  position: relative;
}

.image-tools-upload-area.hover {
  border-color: var(--accent-blue);
  background: var(--accent-blue-bg);
}

.image-tools-upload-area .image-tools-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  pointer-events: none;
  padding: 0 16px;
}

.image-tools-dropzone {
  display: none;
}

.image-tools-file-list {
  display: none;
}

.image-tools-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
  background: var(--bg-panel);
}

.image-tools-file-item:last-child {
  margin-bottom: 0;
}

.image-tools-file-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  background: #3a3a3a;
  flex-shrink: 0;
}

.image-tools-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-tools-file-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.image-tools-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-tools-file-meta {
  color: var(--text-secondary);
  font-size: 11px;
}

.image-tools-file-remove {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-tools-file-remove:hover {
  background: var(--accent-red);
  color: #fff;
}

.image-tools-option-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
}

.image-tools-option-tab {
  padding: 5px 10px;
  border-radius: 3px;
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

.image-tools-option-tab.active {
  background: var(--button-primary);
  border-color: var(--button-primary);
  color: #fff;
}

.image-tools-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.image-tools-inputs.hidden {
  display: none;
}

.image-tools-input-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-primary);
}

.image-tools-input-row label {
  flex-shrink: 0;
  cursor: default;
}

.image-tools-format-note {
  width: 100%;
  font-size: 11px;
  color: var(--accent-red);
  margin-top: 4px;
}

.image-tools-inputs input[type="number"] {
  width: 80px;
}

.image-tools-inputs input[type="range"] {
  width: 160px;
}

/* 宽高输入行 */
.image-tools-dim-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.image-tools-dim-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.image-tools-dim-label,
.image-tools-scale-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.image-tools-dim-field input[type="number"] {
  width: 90px;
}

.image-tools-dim-unit select {
  height: 28px;
  padding: 4px 6px;
  font-size: 12px;
}

/* 锁定宽高比 */
.image-tools-lock-ratio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.image-tools-lock-ratio input {
  cursor: pointer;
}

/* 比例滑块 */
.image-tools-scale-presets {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  flex-shrink: 0;
}

.image-tools-scale-presets span {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-secondary);
}

.image-tools-scale-presets button {
  padding: 5px 4px;
  font-size: 11px;
}

.image-tools-scale-presets button.active {
  background: var(--button-primary);
  border-color: var(--button-primary);
  color: #fff;
}

.image-tools-scale-hint {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--accent-blue-light);
}

/* 推荐尺寸 */
.image-tools-recommended {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex-shrink: 0;
}

.image-tools-recommended span {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-secondary);
}

.image-tools-recommended button {
  padding: 5px 4px;
  font-size: 11px;
}

.image-tools-result {
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
  border-top: 1px solid var(--border-color);
  padding: 10px 12px;
  background: var(--bg-panel);
  font-size: 12px;
}

.image-tools-status-bar {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
}

.image-tools-status-bar.ok { color: var(--accent-green); }
.image-tools-status-bar.warn { color: var(--accent-red); }
.image-tools-status-bar.error { color: var(--accent-red); }

.image-tools-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}

.image-tools-result-item:last-child {
  border-bottom: none;
}

.image-tools-result-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  background: #3a3a3a;
  flex-shrink: 0;
}

.image-tools-result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-tools-result-info {
  flex: 1;
  min-width: 0;
}

.image-tools-result-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-tools-result-meta {
  color: var(--text-secondary);
  font-size: 11px;
}

.image-tools-result-actions {
  display: flex;
  gap: 6px;
}

.image-tools-empty {
  color: var(--text-secondary);
  font-size: 12px;
  padding: 8px 0;
}

.image-tools-empty-title {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 500;
}

.image-tools-empty-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.image-tools-drop-hint {
  text-align: center;
  padding: 10px 0 4px;
  color: var(--text-secondary);
  font-size: 11px;
  border-top: 1px dashed var(--border-light);
  margin-top: 4px;
  pointer-events: none;
}

/* ===== 图片分割 ===== */
.image-tools-split-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.image-tools-split-sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.image-tools-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
}

.image-tools-section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.image-tools-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 10px 0 6px;
}

.image-tools-split-modes,
.image-tools-shape-types,
.image-tools-grid-layouts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.image-tools-split-modes.two-col {
  grid-template-columns: repeat(2, 1fr);
}

.image-tools-shape-types {
  grid-template-columns: repeat(3, 1fr);
}

.image-tools-grid-layouts {
  grid-template-columns: repeat(3, 1fr);
}

.image-tools-grid-inputs {
  display: flex;
  gap: 12px;
  align-items: center;
}

.image-tools-grid-inputs label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-primary);
}

.image-tools-grid-inputs input[type="number"] {
  width: 60px;
}

.image-tools-split-mode,
.image-tools-shape-type,
.image-tools-grid-layouts button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.image-tools-split-mode .mode-icon,
.image-tools-shape-type span:first-child {
  font-size: 16px;
  line-height: 1;
}

.image-tools-split-mode.active,
.image-tools-shape-type.active,
.image-tools-grid-layouts button.active {
  background: var(--button-primary);
  border-color: var(--button-primary);
  color: #fff;
}

.image-tools-range-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.image-tools-range-max {
  font-size: 10px;
}

.image-tools-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  cursor: pointer;
}

.image-tools-toggle input {
  cursor: pointer;
}

.image-tools-split-actions {
  display: flex;
  gap: 6px;
}

.image-tools-status {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.image-tools-part-info {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.image-tools-section.hidden {
  display: none;
}

.image-tools-file-error {
  font-size: 11px;
  color: var(--accent-red);
  margin-top: 2px;
}

.image-tools-split-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.image-tools-canvas-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  position: relative;
  overflow: auto;
}

.image-tools-canvas-shell.hover {
  border-color: var(--accent-blue);
  background: var(--accent-blue-bg);
}

.image-tools-canvas-shell canvas {
  position: absolute;
  cursor: crosshair;
}

.image-tools-canvas-placeholder {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  pointer-events: none;
}

.image-tools-canvas-placeholder.hidden {
  display: none;
}

.image-tools-split-bottom {
  flex-shrink: 0;
  max-height: 160px;
  border-top: 1px solid var(--border-color);
  padding: 10px 12px;
  background: var(--bg-panel);
  display: flex;
  gap: 12px;
  overflow: hidden;
}

.image-tools-split-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
}

.image-tools-split-piece {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.image-tools-split-piece-wrap {
  position: relative;
  max-height: 100px;
  max-width: 120px;
}

.image-tools-split-piece img {
  max-height: 100px;
  max-width: 120px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: #1e1e1e;
  object-fit: contain;
  display: block;
}

.image-tools-split-piece-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
}

.image-tools-split-piece-wrap:hover .image-tools-split-piece-overlay {
  display: flex;
}

.image-tools-split-piece-download {
  padding: 5px 10px;
  border-radius: 4px;
  border: none;
  background: var(--button-primary);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.image-tools-split-piece-download:hover {
  background: var(--button-primary-hover);
}

.image-tools-split-piece span {
  font-size: 11px;
  color: var(--text-secondary);
}

.image-tools-split-actions-bottom {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
