/* compress.css - 图片压缩工具专用样式 */

/* Editor Layout */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 24px;
  margin-top: 20px;
}

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

/* Preview Container */
.preview-container {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.preview-wrapper {
  margin-top: 16px;
}

.preview-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .preview-compare {
    grid-template-columns: 1fr;
  }
}

.preview-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-box canvas {
  max-width: 100%;
  max-height: 250px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.preview-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--gray-500);
}

.ratio-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ratio-badge.positive {
  background: var(--secondary);
}

.ratio-badge.negative {
  background: #ef4444;
}

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

.control-section {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.control-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.control-group {
  margin-bottom: 16px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.range-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--gray-200);
  border-radius: 3px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

.range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.radio-group,
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.radio-option,
.checkbox-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--gray-700);
}

.radio-option input,
.checkbox-option input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.size-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-size-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.size-input {
  width: 80px;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
}

.size-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.size-separator {
  color: var(--gray-500);
  font-weight: 500;
}

.lock-ratio {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--gray-600);
}

.lock-ratio input {
  accent-color: var(--primary);
}

/* Preset Buttons */
.preset-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-btn,
.preset-buttons .btn {
  font-size: 0.8rem;
  padding: 8px 12px;
  width: 100%;
}

/* Download Section */
.download-section {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.download-section .btn {
  width: 100%;
}

/* Batch Section */
.batch-section {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}

.batch-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.batch-list {
  margin-top: 16px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.batch-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  transition: background 0.15s;
}

.batch-item:last-child {
  border-bottom: none;
}

.batch-item:hover {
  background: var(--gray-50);
}

.batch-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.batch-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.batch-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.batch-item-details {
  font-size: 0.8rem;
  color: var(--gray-500);
  display: flex;
  gap: 12px;
}

.batch-item-status {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.batch-item-status.pending {
  background: var(--gray-100);
  color: var(--gray-600);
}

.batch-item-status.compressing {
  background: #fef3c7;
  color: #92400e;
}

.batch-item-status.completed {
  background: #d1fae5;
  color: #065f46;
}

.batch-item-status.error {
  background: #fee2e2;
  color: #991b1b;
}

.batch-item-actions {
  display: flex;
  gap: 8px;
}

.batch-item-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  color: var(--gray-600);
  transition: all 0.15s;
}

.batch-item-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef2ff;
}

/* History Section */
.history-section {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}

.history-list {
  margin-top: 16px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  transition: background 0.15s;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background: var(--gray-50);
}

.history-item-date {
  font-size: 0.8rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.history-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-details {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.history-item-actions {
  display: flex;
  gap: 8px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-500);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--gray-800);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 120px);
}

.preset-list {
  margin-bottom: 16px;
}

.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 8px;
}

.preset-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-800);
}

.preset-item-details {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.preset-item-actions {
  display: flex;
  gap: 8px;
}

.preset-save {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.preset-name-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
}

.preset-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* Image Info */
.image-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--gray-500);
}

/* Checkerboard Background */
.checkerboard-bg {
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
}

/* Responsive */
@media (max-width: 600px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .preview-compare {
    grid-template-columns: 1fr;
  }

  .batch-item {
    flex-wrap: wrap;
  }

  .batch-item-info {
    width: 100%;
  }

  .batch-item-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .history-item {
    flex-wrap: wrap;
  }

  .history-item-info {
    width: 100%;
  }

  .history-item-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
