/* GIF 拆解合成工具特定样式 */
.tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.4);
  padding: 3px;
  border-radius: 9px;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: fit-content;
  margin-right: 8px; /* 与后续按钮保持间距 */
}

.light-theme .tabs {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.05);
}

.tab-btn {
  padding: 5px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  color: var(--text-secondary, #9ca3af);
  border: none;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.light-theme .tab-btn {
  color: #64748b;
}

.tab-btn:hover {
  color: var(--text-primary, #e5e7eb);
  background: rgba(255, 255, 255, 0.05);
}

.light-theme .tab-btn:hover {
  color: #1e293b;
  background: rgba(0, 0, 0, 0.03);
}

.tab-btn.active {
  background: var(--primary-color, #10b981);
  color: white !important;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.light-theme .tab-btn.active {
  background: var(--primary-color, #10b981);
  color: white !important;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.tool-section {
  display: none;
}

.tool-section.active {
  display: block;
}

.editor-area {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

/* 结果显示区域 */
.result-section {
  display: none;
  height: 100%;
  overflow-y: auto; /* 关键：超出高度显示滚动条 */
}

.result-section.active {
  display: flex;
  flex-direction: column;
}

.result-section > div:not(.result-placeholder) {
  padding: 16px;
  width: 100%;
  box-sizing: border-box;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  color: var(--text-secondary, #9ca3af);
  gap: 16px;
  font-size: 14px;
}

.result-placeholder div:first-child {
  font-size: 48px;
  opacity: 0.5;
}

.light-theme .result-placeholder {
  color: #64748b;
}

@media (max-width: 992px) {
  .editor-area {
    grid-template-columns: 1fr;
  }
}

/* 拆解后的帧预览 */
.frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 0;
  padding: 0 !important; /* 抵消父元素的 padding，由父元素统一控制 */
}

.frame-item {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid var(--border-color, #1f2937);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.light-theme .frame-item {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.frame-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.frame-actions {
  position: absolute;
  top: 12px; /* 与 frame-item 的 padding 一致 */
  left: 12px;
  right: 12px;
  height: 120px; /* 与 img 的高度一致 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px; /* 与 img 的圆角一致 */
  transition: opacity 0.2s;
  z-index: 2;
  backdrop-filter: blur(2px);
}

.frame-item:hover .frame-actions {
  opacity: 1;
}

.frame-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%; /* 圆形按钮更美观 */
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.frame-action-btn:hover {
  background: #10b981;
  border-color: #10b981;
}

.frame-action-btn.delete:hover {
  background: #ef4444;
  border-color: #ef4444;
}

.frame-item img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 8px;
  background-image: 
    linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%), 
    linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.light-theme .frame-item img {
  background-image: 
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%, #f1f5f9 100%), 
    linear-gradient(45deg, #f1f5f9 25%, white 25%, white 75%, #f1f5f9 75%, #f1f5f9 100%);
}

.frame-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary, #9ca3af);
  padding: 0 4px;
}

.light-theme .frame-info {
  color: #64748b;
}

.frame-number {
  font-weight: 600;
  color: var(--primary-color, #10b981);
}

.frame-delay {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-color, #10b981);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* 合成的图片列表 */
.merge-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 0;
  padding: 0 !important; /* 抵消父元素的 padding，由父元素统一控制 */
}

.settings-panel {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.light-theme .settings-panel {
  background: rgba(241, 245, 249, 0.5);
  border-color: rgba(203, 213, 225, 0.5);
}

.image-preview {
  position: relative;
  margin-bottom: 24px;
  text-align: center;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color, #1f2937);
  border-radius: 16px;
  padding: 24px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.light-theme .image-preview {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.merge-item {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid var(--border-color, #1f2937);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.light-theme .merge-item {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.merge-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--primary-color, #10b981);
}

.merge-item img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 8px;
  background-image: 
    linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%), 
    linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.light-theme .merge-item img {
  background-image: 
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%, #f1f5f9 100%), 
    linear-gradient(45deg, #f1f5f9 25%, white 25%, white 75%, #f1f5f9 75%, #f1f5f9 100%);
  border-color: rgba(0, 0, 0, 0.05);
}

.merge-item-info {
  font-size: 11px;
  color: var(--text-secondary, #9ca3af);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.merge-item-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(16, 185, 129, 0.9);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
  z-index: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.merge-item-actions {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  transition: opacity 0.2s;
  z-index: 2;
  backdrop-filter: blur(2px);
}

.merge-item:hover .merge-item-actions {
  opacity: 1;
}

.merge-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.merge-action-btn:hover {
  background: #10b981;
  border-color: #10b981;
}

.merge-action-btn.delete:hover {
  background: #ef4444;
  border-color: #ef4444;
}

.merge-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.05);
}

/* 拖拽排序样式 */
.merge-item.dragging {
  opacity: 0.5;
  background: rgba(var(--primary-rgb, 16, 185, 129), 0.1);
  border-style: dashed;
}

.drop-area {
  border: 2px dashed rgba(148, 163, 184, 0.3);
  border-radius: 20px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(30, 41, 59, 0.2);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.drop-area.has-preview {
  padding: 20px;
  border-style: solid;
  border-color: var(--primary-color, #10b981);
  background: rgba(var(--primary-rgb, 16, 185, 129), 0.05);
}

.drop-area.has-preview .drop-area-icon,
.drop-area.has-preview .drop-area-text,
.drop-area.has-preview .drop-area-hint {
  display: none;
}

.drop-area-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  object-fit: contain;
  background-image: 
    linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%), 
    linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.light-theme .drop-area-preview {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background-image: 
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%, #f1f5f9 100%), 
    linear-gradient(45deg, #f1f5f9 25%, white 25%, white 75%, #f1f5f9 75%, #f1f5f9 100%);
}

.light-theme .drop-area {
  background: rgba(248, 250, 252, 0.8);
  border-color: rgba(203, 213, 225, 0.8);
}

.drop-area:hover, .drop-area.dragover {
  border-color: var(--primary-color, #10b981);
  background: rgba(16, 185, 129, 0.08);
  transform: scale(1.01);
}

.drop-area-icon {
  font-size: 48px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.drop-area-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #e5e7eb);
  margin-bottom: 4px;
}

.light-theme .drop-area-text {
  color: #1e293b;
}

.drop-area-hint {
  font-size: 13px;
  color: var(--text-secondary, #9ca3af);
}

.light-theme .drop-area-hint {
  color: #64748b;
}

.preview-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  background-image: 
    linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%), 
    linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

#deleteImageBtn {
  margin-top: 10px;
}

#deleteImageBtn:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: #ef4444 !important;
  color: #ef4444 !important;
}

.header .action-bar {
  margin-top: 0;
}

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

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  transition: all 0.2s ease;
}

.setting-item:hover {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(16, 185, 129, 0.3);
}

.light-theme .setting-item {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(0, 0, 0, 0.05);
}

.light-theme .setting-item:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(16, 185, 129, 0.2);
}

.setting-item label {
  font-size: 14px;
  color: var(--text-secondary, #9ca3af);
  font-weight: 500;
}

.light-theme .setting-item label {
  color: #475569;
}

.setting-item input {
  background: var(--bg-secondary, #0f172a);
  border: 1px solid var(--border-color, #1f2937);
  color: var(--text-primary, #e5e7eb);
  padding: 8px 12px;
  border-radius: 8px;
  width: 100px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.light-theme .setting-item input {
  background: #fff;
  color: #1e293b;
}

.setting-item input:focus {
  border-color: var(--primary-color, #10b981);
}

@media (max-width: 640px) {
  .settings-panel {
    flex-direction: column;
    gap: 16px;
  }
  
  .setting-item {
    justify-content: space-between;
  }
  
  .setting-item input {
    width: 120px;
  }
}

