/* ImageToolkit — Global Styles */
:root {
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --green: #10B981;
  --green-hover: #059669;
  --border: #E2E8F0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-width: 1100px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Nav */
.nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.nav-brand span { color: var(--accent); }
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--accent);
  background: #EFF6FF;
}
.nav-coffee {
  background: #FEF3C7 !important;
  color: #92400E !important;
  font-weight: 600 !important;
}
.nav-coffee:hover { background: #FDE68A !important; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

/* Main */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
  flex: 1;
}

/* Hero */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.hero h1 span { color: var(--accent); }
.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Privacy badge */
.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ECFDF5;
  color: #065F46;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  margin-top: 1.25rem;
}
.privacy-badge svg { flex-shrink: 0; }

/* Tool grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.tool-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.tool-card-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}
.tool-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.tool-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Sections */
.section-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
}

.trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}
.trust-item {
  text-align: center;
  padding: 1.25rem;
}
.trust-item .icon { font-size: 2rem; margin-bottom: 0.5rem; }
.trust-item h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; }
.trust-item p { font-size: 0.85rem; color: var(--text-muted); }

.comparison {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 2rem 0;
  text-align: center;
}
.comparison h2 { margin-bottom: 1rem; }
.comparison table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 auto;
  max-width: 600px;
}
.comparison th, .comparison td {
  padding: 0.6rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.comparison th { font-weight: 700; color: var(--text-muted); }
.comparison td:first-child { text-align: left; font-weight: 600; }

/* Tool page layout */
.tool-header {
  text-align: center;
  margin-bottom: 2rem;
}
.tool-header h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}
.tool-header p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-card);
  margin-bottom: 1.5rem;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: #EFF6FF;
}
.drop-zone-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.drop-zone-text { color: var(--text-muted); font-size: 0.95rem; }
.drop-zone-text strong { color: var(--text); }
.drop-zone input[type="file"] { display: none; }

/* Controls */
.controls {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.control-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.control-row:last-child { margin-bottom: 0; }
.control-row label {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 100px;
}
.control-row input[type="range"] {
  flex: 1;
  min-width: 150px;
}
.control-row input[type="number"] {
  width: 100px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.control-row select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fff;
}
.quality-value {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 40px;
  text-align: center;
  color: var(--accent);
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}
.toggle-label input { display: none; }
.toggle-track {
  width: 40px;
  height: 22px;
  background: #CBD5E1;
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-label input:checked + .toggle-track {
  background: var(--accent);
}
.toggle-label input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* Presets */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.preset-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); }
.preset-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #94A3B8; cursor: not-allowed; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-hover); }
.btn-green:disabled { background: #94A3B8; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* Results / file list */
.results {
  margin-top: 1.5rem;
}
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.results-header h2 { font-size: 1.15rem; }
.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.file-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.file-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 150px; }
.file-name { font-weight: 600; font-size: 0.9rem; word-break: break-all; }
.file-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.file-savings {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green);
  background: #ECFDF5;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.file-actions { display: flex; gap: 0.5rem; }

/* Preview area */
.preview-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
  text-align: center;
}
.preview-area img, .preview-area canvas {
  max-width: 100%;
  max-height: 500px;
  border-radius: 6px;
}

/* Crop canvas container */
.crop-container {
  position: relative;
  display: inline-block;
  cursor: crosshair;
}
.crop-container canvas {
  display: block;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 1rem 0;
  display: none;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1rem;
  text-align: center;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.footer p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

/* Error message */
.error-msg {
  background: #FEF2F2;
  color: #991B1B;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 1rem 0;
  display: none;
}
.error-msg.show { display: block; }

/* Mobile */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.75rem; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .nav-links.open { display: flex; }
  .drop-zone { padding: 2rem 1rem; }
  .control-row { flex-direction: column; align-items: stretch; }
  .control-row label { min-width: auto; }
  .file-item { flex-direction: column; align-items: flex-start; }
  .comparison table { font-size: 0.8rem; }
  .comparison th, .comparison td { padding: 0.4rem 0.5rem; }
}
