/* =========================================================
   Image Compressor & Converter — Stylesheet
   ========================================================= */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --border: #e2e5ee;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --primary: #1f6feb;
  --primary-hover: #1a5fd0;
  --primary-soft: #e7f0ff;
  --success: #17a865;
  --success-soft: #e6f8ef;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warning: #b7791f;
  --warning-soft: #fff8e6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 24px rgba(20, 22, 40, 0.06);
  --shadow-lg: 0 16px 40px rgba(20, 22, 40, 0.12);
  --header-h: 68px;
}

[data-theme="dark"] {
  --bg: #12131c;
  --surface: #1b1d29;
  --surface-2: #23253377;
  --border: #2c2e3d;
  --text: #eef0f8;
  --text-muted: #9498ab;
  --primary: #4d9fff;
  --primary-hover: #6bb0ff;
  --primary-soft: #16233a;
  --success: #34d399;
  --success-soft: #10281f;
  --danger: #ff6b6f;
  --danger-soft: #341518;
  --warning: #f2c14e;
  --warning-soft: #332a10;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: inherit; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */

.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-weight: 800;
  font-size: 1.5rem;
  text-decoration: none;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.brand .logo-dot {
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 0 6px;
  margin-right: 2px;
  font-size: 1.5rem;
}
.brand .brand-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 6px;
  align-self: center;
}

.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.main-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); }
.main-nav a.active { color: var(--primary); background: var(--primary-soft); }

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  width: 42px; height: 42px;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text);
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
}
.theme-toggle:hover { border-color: var(--primary); }

/* ---------- Hero ---------- */

.hero {
  text-align: center;
  padding: 52px 0 28px;
}

.hero h1 {
  font-size: clamp(1.7rem, 3.2vw, 2.6rem);
  margin: 0 0 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
  font-size: 1.05rem;
}

.hero .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}

.badge {
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.muted { background: var(--surface-2); color: var(--text-muted); }

/* ---------- Dropzone ---------- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  margin-top: 8px;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: scale(1.01);
}

.dropzone .icon {
  font-size: 2.6rem;
  margin-bottom: 10px;
}

.dropzone h3 { margin: 0 0 6px; font-size: 1.15rem; }
.dropzone p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }

.dropzone input[type="file"] { display: none; }

.dz-browse-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 22px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---------- Global controls panel ---------- */

.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 22px;
  display: none;
}
.controls-panel.visible { display: block; }

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: flex-end;
}

.control-group { flex: 1 1 220px; min-width: 200px; }

.control-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.preset-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
}
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

select, .text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
}

.quality-value {
  font-weight: 700;
  color: var(--primary);
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s ease, background 0.15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }

.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* ---------- Progress ---------- */

.global-progress {
  margin-top: 16px;
  display: none;
}
.global-progress.visible { display: block; }

.progress-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #9b6bff);
  transition: width 0.2s ease;
}
.progress-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ---------- Summary strip ---------- */

.summary-strip {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.summary-card {
  flex: 1 1 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.summary-card .label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.summary-card .value { font-size: 1.35rem; font-weight: 800; margin-top: 4px; }
.summary-card.saved .value { color: var(--success); }

/* ---------- Image grid / cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: cardIn 0.35s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%) -8px 0/16px 16px,
    linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%) -8px 0/16px 16px,
    linear-gradient(45deg, transparent 75%, var(--surface-2) 75%) -8px 0/16px 16px,
    linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%) -8px 0/16px 16px;
  overflow: hidden;
}

.card-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card-preview .compare-slider {
  position: absolute;
  inset: 0;
}
.compare-slider .after-wrap {
  position: absolute; inset: 0; overflow: hidden; width: 50%;
}
.compare-slider .after-wrap img { width: var(--cmp-w, 100%); height: 100%; object-fit: contain; position: absolute; left: 0; top: 0; }
.compare-slider input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}
.compare-handle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
  pointer-events: none;
}
.compare-handle::after {
  content: "⇔";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 30px; height: 30px;
  background: #fff;
  color: #222;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 2;
}
.card-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 2;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
}

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }

.card-title {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.size-compare {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.size-compare .orig { color: var(--text-muted); text-decoration: line-through; }
.size-compare .new { font-weight: 800; color: var(--success); }
.size-compare .pct {
  background: var(--success-soft);
  color: var(--success);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
}

.card-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.countdown.warn { color: var(--warning); }
.countdown.danger { color: var(--danger); }

.card-controls { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.card-controls .row { display: flex; gap: 8px; }
.card-controls select, .card-controls .btn { flex: 1; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
  max-width: 320px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  animation: toastIn 0.25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- Info sections ---------- */

.features {
  margin-top: 70px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.feature-card .emoji { font-size: 1.6rem; margin-bottom: 8px; display: block; }
.feature-card h4 { margin: 0 0 6px; font-size: 1rem; }
.feature-card p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

.faq {
  margin-top: 60px;
}
.faq h2 { text-align: center; margin-bottom: 24px; }
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 10px;
}
.faq-item summary { cursor: pointer; font-weight: 700; font-size: 0.95rem; }
.faq-item p { color: var(--text-muted); margin: 10px 0 0; font-size: 0.88rem; }

footer {
  text-align: center;
  padding: 40px 20px 60px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--text-muted);
  display: none;
}
.empty-state.visible { display: block; }

@media (max-width: 640px) {
  .dropzone { padding: 34px 16px; }
  .controls-row { gap: 14px; }
  .summary-strip { flex-direction: column; }
}

/* =========================================================
   11zon-style tool panel: tabs, slider, size, fabs, ads
   ========================================================= */

.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 18px;
  box-shadow: var(--shadow);
  display: none;
}
.tool-panel.visible { display: block; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px 16px 0;
}
.tab {
  flex: 1;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 12px;
  border-radius: 12px 12px 0 0;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.tab.active {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border);
  box-shadow: 0 -2px 0 var(--primary) inset;
}

.tab-content { display: none; padding: 22px; }
.tab-content.active { display: block; }

.field-label {
  display: block;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}
.info-dot {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 1.5px solid var(--text-muted);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 0.75rem;
  font-style: italic;
  vertical-align: middle;
  cursor: help;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.slider-row input[type="range"] {
  flex: 1;
  min-width: 180px;
  height: 8px;
}
.slider-number, .target-input {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  min-width: 90px;
}
.slider-number input, .target-input input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 800;
  width: 60px;
  text-align: right;
  outline: none;
}
.target-input input { font-size: 1.4rem; }
.pct-sign { font-size: 1.1rem; font-weight: 700; color: var(--text-muted); }

.quick-sizes { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip:hover, .chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; justify-content: center; font-size: 1rem; padding: 14px; }
.btn-lg { padding: 15px 26px; font-size: 1.05rem; }

/* Floating action buttons */
.fab-stack {
  position: fixed;
  right: 20px;
  bottom: 90px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 40;
}
.fab {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease;
}
.fab:active { transform: scale(0.92); }
.fab-del { background: var(--danger); font-size: 1.2rem; }

.zip-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: center;
  z-index: 45;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.06);
}
.zip-bar .btn { max-width: 420px; width: 100%; justify-content: center; }

/* Ad slots */
.ad-slot {
  margin: 24px auto;
  text-align: center;
  min-height: 10px;
  overflow: hidden;
}
.ad-slot-sidebar { margin: 0; }

/* SEO content block */
.seo-content {
  margin-top: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 30px;
  line-height: 1.7;
}
.seo-content h2 { margin-top: 0; font-size: 1.5rem; }
.seo-content h3 { font-size: 1.15rem; margin-top: 22px; }
.seo-content p { color: var(--text-muted); }

.footer-nav {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.footer-nav a { color: var(--text-muted); text-decoration: none; font-size: 0.85rem; }
.footer-nav a:hover { color: var(--primary); }

/* Result row inside cards (compress-only) */
.card-badge.tosize { background: var(--primary); }

@media (max-width: 860px) {
  .main-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 10px;
    box-shadow: var(--shadow-lg);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px; }
  .nav-toggle { display: flex; align-items: center; justify-content: center; }
  .brand { font-size: 1.25rem; }
}
