/* ============================================================
   DESIGN SYSTEM — Minimal Modern Image Editor
   ============================================================ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #38adca;
  --accent-soft: #eef2ff;
  --success: #16a34a;
  --success-hover: #15803d;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --warning: #d97706;
  --info: #0891b2;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 16px 48px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1080px; margin: 0 auto; }

/* ---------- Nav ---------- */
.nav-menu {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.nav-btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 24px;
}

/* ---------- Drop zone ---------- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-zone i { font-size: 2.5rem; color: var(--accent-soft); margin-bottom: 12px; }
.drop-zone h4 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.drop-zone p { color: var(--text-muted); font-size: 13px; margin: 0; }

/* ---------- Buttons ---------- */
.btn, .btn-custom, .btn-primary, .btn-success, .btn-danger, .btn-secondary, .btn-info, .btn-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  text-decoration: none;
}
.btn-custom, .btn-primary { background: var(--accent); color: #fff; }
.btn-custom:hover, .btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--border); }
.btn-info { background: var(--info); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn:active, .btn-custom:active { transform: scale(.98); }

/* Small buttons */
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .15s, border-color .15s;
}
.btn-sm:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }

/* Outline variants */
.btn-outline-primary, .btn-outline-info, .btn-outline-warning,
.btn-outline-success, .btn-outline-secondary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-outline-primary   { color: var(--accent);  border: 1px solid var(--accent); }
.btn-outline-info      { color: var(--info);    border: 1px solid var(--info); }
.btn-outline-warning   { color: var(--warning); border: 1px solid var(--warning); }
.btn-outline-success   { color: var(--success); border: 1px solid var(--success); }
.btn-outline-secondary { color: var(--text-muted); border: 1px solid var(--border-strong); }
.btn-outline-primary:hover   { background: var(--accent);  color:#fff; }
.btn-outline-info:hover      { background: var(--info);    color:#fff; }
.btn-outline-warning:hover   { background: var(--warning); color:#fff; }
.btn-outline-success:hover   { background: var(--success); color:#fff; }
.btn-outline-secondary:hover { background: var(--text-muted); color:#fff; }

/* ---------- Form elements ---------- */
.form-control, select.form-control, input[type="number"], input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, input[type="number"]:focus, input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label { font-weight: 500; font-size: 13px; color: var(--text); display: block; margin-bottom: 6px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
}

.form-range { width: 100%; }
.form-check-input { cursor: pointer; width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Grid ---------- */
.row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.col-md-3 { flex: 1 1 calc(25% - 16px); min-width: 160px; }
.col-md-4 { flex: 1 1 calc(33.333% - 16px); min-width: 200px; }
.col-md-6 { flex: 1 1 calc(50% - 16px); min-width: 220px; }
.col-md-8 { flex: 1 1 calc(66.666% - 16px); min-width: 260px; }
.col-md-12 { flex: 1 1 100%; }
@media (max-width: 720px) {
  .col-md-3, .col-md-4, .col-md-6, .col-md-8 { flex: 1 1 100%; }
}

/* ---------- Utilities ---------- */
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 600; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.gap-2 { gap: 8px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Progress ---------- */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  color: transparent;
  border-radius: 999px;
  transition: width .2s;
}

/* ---------- Result card ---------- */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 13px;
}
.result-card.warning { border-left-color: var(--warning); }
.result-card .result-title { font-weight: 600; margin-bottom: 4px; }
.result-card small { color: var(--text-muted); }

/* ---------- List ---------- */
.list-group-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 8px;
  font-size: 13px;
}

/* ---------- Bulk bar ---------- */
.bulk-bar {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}
.select-all-checkbox { margin-right: 4px; }

/* ---------- Preview ---------- */
.preview-container { margin: 20px 0; text-align: center; }
.preview-image {
  max-width: 100%;
  max-height: 340px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.preview-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}
.slider-group { margin-bottom: 18px; }

/* ---------- Mode cards (resize) ---------- */
.mode-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.mode-card:hover { border-color: var(--accent); background: var(--surface); }
.mode-card.active { border-color: var(--accent); background: var(--accent-soft); }
.mode-icon { font-size: 1.5rem; display: block; margin-bottom: 8px; color: var(--accent); }
.mode-card strong { font-size: 13px; display: block; }
.mode-card small { font-size: 11px; color: var(--text-muted); }

/* ---------- Canvas (blur/crop) ---------- */
.canvas-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px;
  border: 1px solid var(--border);
}
.canvas-wrapper canvas {
  max-width: 100%; height: auto;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  display: block;
}
.selection-box {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(79,70,229,.15);
  display: none;
  pointer-events: none;
  border-radius: 4px;
}
.controls {
  margin: 16px 0;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.info-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.selected-area-info {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--accent);
  display: none;
}

/* ---------- Alert ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-info { background: var(--accent-soft); color: var(--accent); border: 1px solid #c7d2fe; }

/* ---------- Color picker ---------- */
.color-picker-wrapper { display: flex; align-items: center; gap: 10px; }
.color-preview { width: 42px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); }
input[type="color"] { width: 46px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); cursor: pointer; padding: 2px; background: var(--surface); }

/* ---------- Preview gallery (convert_all) ---------- */
.preview-gallery { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.preview-gallery h5 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px;
}
.preview-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.preview-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.preview-card.active { border-color: var(--accent); background: var(--accent-soft); }
.preview-card img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.preview-card .file-name { font-size: 11px; margin-top: 6px; color: var(--text-muted); word-break: break-all; }
.preview-card .file-size { font-size: 10px; color: var(--success); }
.main-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.main-preview img { max-width: 100%; max-height: 240px; border-radius: var(--radius-sm); }
.preview-info { font-size: 12px; color: var(--text-muted); }
.selected-file-info { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; font-size: 12px; color: var(--accent); }
.quality-control { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }