/*
   Image Converter — Tool CSS v0.5
   Variables use --ic- prefix to avoid collision with common.css
*/

:root {
  --ic-accent: #2563eb;
  --ic-accent-hover: #1d4ed8;
  --ic-surface: #f8f9fa;
  --ic-border: #e2e5e9;
  --ic-text-sub: #6b7280;
  --ic-text-muted: #9ca3af;
  --ic-radius: 10px;
  --ic-radius-lg: 14px;
  --ic-green: #16a34a;
  --ic-red: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ic-accent: #3b82f6;
    --ic-accent-hover: #2563eb;
    --ic-surface: #1e1e1e;
    --ic-border: #333;
    --ic-text-sub: #9ca3af;
    --ic-text-muted: #6b7280;
  }
}

/* --- Tool Header --- */
.tool-header {
  text-align: center;
  margin-bottom: 28px;
}

.tool-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.tool-sub {
  font-size: 13px;
  color: var(--ic-text-sub);
}

/* --- Drop Zone --- */
.drop-zone {
  border: 2px dashed var(--ic-border);
  border-radius: var(--ic-radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  background: var(--ic-surface);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--ic-accent);
  background: rgba(37, 99, 235, 0.04);
}

.drop-zone.has-file {
  cursor: default;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone.has-file input[type="file"] {
  pointer-events: none;
}

.drop-icon {
  color: var(--ic-text-muted);
  margin-bottom: 12px;
}

.drop-text {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.drop-hint {
  font-size: 13px;
  color: var(--ic-text-sub);
  margin-bottom: 8px;
}

.drop-formats {
  font-size: 12px;
  color: var(--ic-text-muted);
}

.drop-formats-note {
  font-size: 11px;
  color: var(--ic-text-muted);
  margin-top: 4px;
}

/* --- File Info --- */
.file-info {
  display: none;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--ic-surface);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
}

.file-info.visible {
  display: block;
}

.file-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.file-name {
  font-weight: 600;
  font-size: 14px;
  word-break: break-all;
}

.file-meta {
  font-size: 12px;
  color: var(--ic-text-sub);
}

/* --- Preview --- */
.preview-area {
  display: none;
  margin-top: 16px;
  text-align: center;
  background:
    repeating-conic-gradient(#d1d5db 0% 25%, transparent 0% 50%)
    50% / 16px 16px;
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  padding: 12px;
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {
  .preview-area {
    background:
      repeating-conic-gradient(#444 0% 25%, transparent 0% 50%)
      50% / 16px 16px;
  }
}

.preview-area.visible {
  display: block;
}

.preview-area canvas {
  max-width: 100%;
  max-height: 400px;
  display: block;
  margin: 0 auto;
}

/* --- Format Section --- */
.format-section {
  display: none;
  margin-top: 20px;
}

.format-section.visible {
  display: block;
}

.section-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.format-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.format-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.format-option:hover {
  border-color: var(--ic-accent);
}

.format-option:has(input:checked) {
  border-color: var(--ic-accent);
  background: rgba(37, 99, 235, 0.06);
}

.format-option input[type="radio"] {
  display: none;
}

/* --- Advanced Settings --- */
.advanced {
  display: none;
  margin-top: 16px;
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  overflow: hidden;
}

.advanced.visible {
  display: block;
}

.advanced summary {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ic-text-sub);
  user-select: none;
}

.advanced summary:hover {
  color: var(--ic-accent);
}

.advanced-inner {
  padding: 0 16px 16px;
}

/* --- Setting Groups --- */
.setting-group {
  margin-bottom: 16px;
}

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

.setting-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.resize-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.resize-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

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

.custom-size input[type="number"] {
  width: 90px;
  padding: 6px 8px;
  border: 1px solid var(--ic-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--ic-surface);
  color: inherit;
}

.custom-size .unit {
  font-size: 12px;
  color: var(--ic-text-sub);
}

.lock-ratio {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--ic-text-sub);
}

/* Quality Slider */
#qualitySlider {
  width: 100%;
  margin-top: 4px;
}

/* Background color options */
.bg-options {
  display: flex;
  gap: 16px;
  font-size: 13px;
  flex-wrap: wrap;
}

.bg-options label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.bg-options input[type="color"] {
  width: 28px;
  height: 28px;
  border: 1px solid var(--ic-border);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
}

/* --- Convert Button --- */
.btn-convert {
  display: none;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--ic-radius);
  background: var(--ic-accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-convert.visible {
  display: block;
}

.btn-convert:hover:not(:disabled) {
  background: var(--ic-accent-hover);
}

.btn-convert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-convert.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* --- Status --- */
.status {
  margin-top: 12px;
  padding: 0;
  font-size: 13px;
  text-align: center;
  min-height: 20px;
}

.status.success {
  color: var(--ic-green);
}

.status.error {
  color: var(--ic-red);
}

/* --- SEO Content --- */
.seo-content {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--ic-border);
}

.seo-section {
  margin-bottom: 28px;
}

.seo-section h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.seo-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.seo-section p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ic-text-sub);
}

.faq-item {
  margin-bottom: 16px;
}

.learn-list {
  list-style: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ic-text-sub);
}

/* --- Mobile --- */
@media (max-width: 480px) {
  .tool-header h1 { font-size: 20px; }
  .drop-zone { padding: 36px 16px; }
  .format-options { grid-template-columns: repeat(2, 1fr); }
  .custom-size input[type="number"] { width: 80px; }
}
