/* Premium Photo Enhancer - styles */

:root {
  --accent-1: #7C3AED;
  --accent-2: #C084FC;
  --ink: #1E1B2E;
  --ink-soft: #6B7280;
  --border: #E5E7EB;
  --bg-soft: #FAF5FF;
  --danger: #DC2626;
  --success: #059669;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(160deg, #F5F3FF 0%, #EEF2FF 45%, #F8FAFC 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 70px 20px 40px;
}

.glass-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(124, 58, 237, 0.10), 0 2px 8px rgba(0,0,0,0.04);
  padding: 28px 24px;
}

.info-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg-soft);
  border: 1px solid #E9D5FF;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: #5B21B6;
  margin-bottom: 22px;
}
.info-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}
.app-icon svg { width: 28px; height: 28px; }

.app-title {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.app-subtitle {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 28px;
}

.screen { display: none; }
.screen.active { display: block; }

/* ---------------- Upload ---------------- */
.upload-zone {
  border: 2px dashed #E9D5FF;
  border-radius: 18px;
  background: var(--bg-soft);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent-1);
  background: #F3E8FF;
}
.upload-icon { width: 46px; height: 46px; color: var(--accent-1); margin-bottom: 14px; }
.upload-text { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.upload-subtext { color: var(--ink-soft); font-size: 13px; margin-bottom: 14px; }
.btn-choose {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  border: none;
  padding: 11px 26px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.upload-meta { margin-top: 16px; font-size: 12px; color: #9CA3AF; }

.upload-progress-card {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}
.upload-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.spinner {
  width: 22px; height: 22px; flex: none;
  animation: spin 0.9s linear infinite;
}
.spinner circle { stroke: var(--accent-1); stroke-dasharray: 46; stroke-dashoffset: 14; stroke-linecap: round; }
@keyframes spin { to { transform: rotate(360deg); } }
.upload-progress-text { flex: 1; min-width: 0; text-align: left; }
.upload-progress-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-progress-label { font-size: 12px; color: var(--ink-soft); }
.upload-progress-percent { font-size: 15px; font-weight: 800; color: var(--accent-1); flex: none; }
.upload-progress-track { height: 6px; background: var(--bg-soft); border-radius: 6px; overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); transition: width 0.2s ease; }

/* ---------------- Configure layout ---------------- */
.configure-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 720px) {
  .configure-layout { grid-template-columns: 1fr; }
}

.preview-panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
.preview-frame {
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-frame img { width: 100%; height: auto; max-height: 480px; object-fit: contain; display: block; }
.preview-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent-1);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.options-panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.option-row.sub-row { padding-left: 4px; }
.option-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option-label { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.option-hint { font-size: 11.5px; color: var(--ink-soft); }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0; background: #D1D5DB; border-radius: 20px;
  transition: background-color 0.15s ease;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.15s ease;
}
.switch input:checked ~ .switch-track { background: var(--accent-1); }
.switch input:checked ~ .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible ~ .switch-track { box-shadow: 0 0 0 3px rgba(124,58,237,0.3); }

.form-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  flex: none;
  width: 120px;
}

.hint-text { font-size: 11.5px; color: var(--ink-soft); border-top: 1px dashed var(--border); padding-top: 12px; }

/* ---------------- Before/after compare slider ---------------- */
/* Shown at 50% of the frame's previous size, per explicit request --
   centered under the same max-width so the slider track below still
   lines up with the (now smaller) image above it. */
.compare-wrap { margin: 18px auto 22px; max-width: 50%; }
.compare-frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  user-select: none;
  cursor: ew-resize;
  /* Dragging the divider is handled ourselves via Pointer Events (see
     app.js) -- touch-action: none stops the browser's own touch-scroll
     gesture from fighting that drag on mobile. */
  touch-action: none;
}
.compare-img {
  display: block;
  width: 100%;
  height: auto;
  /* Plain <img> elements are draggable by default, which starts the
     browser's native "drag this image out" gesture the instant a user
     presses down to drag the divider -- that native drag captures the
     pointer and never fires our own move/up handlers, which is exactly
     what looked like the page "hanging" until reloaded. Disabling it
     (attribute + these two properties, for full cross-browser coverage)
     lets our own Pointer Events drag handle it instead. */
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
}
.compare-before-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  clip-path: inset(0 50% 0 0);
}
.compare-before-clip .compare-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.compare-divider {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 3px;
  margin-left: -1.5px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  pointer-events: none;
}
.compare-divider::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 34px; height: 34px;
  transform: translate(-50%, -50%);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237C3AED' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 7 4 12l4 5'/%3E%3Cpath d='M16 7l4 5-4 5'/%3E%3C/svg%3E") center/16px no-repeat;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.compare-label {
  position: absolute;
  top: 10px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
  z-index: 3;
}
.compare-label-before { left: 10px; }
.compare-label-after { right: 10px; }
.compare-slider {
  width: 100%;
  margin-top: 12px;
  accent-color: var(--accent-1);
  cursor: pointer;
}

.btn-compress {
  margin-top: 4px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  border: none;
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-compress svg { width: 20px; height: 20px; }
.btn-compress:hover { filter: brightness(1.05); }

/* ---------------- Processing ---------------- */
.processing-screen { text-align: center; padding: 30px 0; }
.progress-circle-wrap { position: relative; width: 170px; height: 170px; margin: 0 auto 20px; }
.progress-circle-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-circle-bg { fill: none; stroke: #EEF2FF; stroke-width: 10; }
.progress-circle-fg {
  fill: none;
  stroke: var(--accent-1);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}
.progress-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
}
.progress-bar-track { height: 6px; background: #EEF2FF; border-radius: 6px; max-width: 340px; margin: 0 auto 16px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); width: 0%; transition: width 0.3s ease; }
.processing-message { font-weight: 700; margin-bottom: 4px; }
.processing-subtext { color: var(--ink-soft); font-size: 13px; }

/* ---------------- Result ---------------- */
.result-screen { text-align: center; padding: 10px 0 0; }
.result-badge {
  width: 64px; height: 64px; border-radius: 50%;
  background: #ECFDF5; color: var(--success);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.result-badge svg { width: 30px; height: 30px; }
.result-title { font-size: 20px; font-weight: 800; margin-bottom: 10px; }

.quality-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #ECFDF5; color: var(--success);
  padding: 6px 14px; border-radius: 30px; font-size: 12.5px; font-weight: 700;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}
@media (max-width: 480px) { .result-stats { grid-template-columns: repeat(1, 1fr); } }
.result-stat { background: var(--bg-soft); border-radius: 12px; padding: 14px 8px; }
.result-stat-label { font-size: 11px; color: var(--ink-soft); margin-bottom: 4px; }
.result-stat-value { font-size: 18px; font-weight: 800; }
.result-stat-value.accent { color: var(--accent-1); }

.download-section { max-width: 380px; margin: 0 auto; }
.download-label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; text-align: left; }
.download-filename-input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px; font-size: 14px;
}
.btn-download {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff; border: none; padding: 14px; border-radius: 14px;
  font-weight: 700; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 10px;
}
.btn-download svg { width: 20px; height: 20px; }
.btn-compress-another {
  width: 100%; background: none; border: none; color: var(--accent-1);
  font-weight: 700; font-size: 14px; cursor: pointer; padding: 8px;
}

.app-footer { text-align: center; color: var(--ink-soft); font-size: 12px; margin-top: 18px; }

/* ---------------- Toasts ---------------- */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100000; display: flex; flex-direction: column; gap: 10px; width: min(420px, 92vw); }
.toast-error {
  background: #fff; border-left: 4px solid var(--danger);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start;
}
.toast-icon { width: 22px; height: 22px; color: var(--danger); flex: none; }
.toast-title { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.toast-message { font-size: 13px; color: var(--ink-soft); }
.toast-close { background: none; border: none; cursor: pointer; color: #9CA3AF; margin-left: auto; }

.d-none { display: none !important; }
