/* ==========================================================================
   TOOL UI — PDF workspace, utility workspace, image workspace layouts
   ========================================================================== */

/* ══════════════════════════════════════════════════════════════════════════
   DROPZONE
   ══════════════════════════════════════════════════════════════════════════ */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-hero);
  background: var(--color-surface);
  padding: var(--space-16) var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  outline: none;
  min-height: 280px;
  position: relative;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--color-primary);
  background: rgb(79 70 229 / .04);
  box-shadow: var(--shadow-focus);
}

/* Drag-over state */
.dropzone--drag-over {
  border-color: var(--color-primary);
  background: rgb(79 70 229 / .08);
  box-shadow: 0 0 0 4px rgb(79 70 229 / .2);
}

[data-theme="dark"] .dropzone--drag-over {
  background: rgb(129 140 248 / .1);
  box-shadow: 0 0 0 4px rgb(129 140 248 / .2);
}

/* Invalid (wrong file type) */
.dropzone--invalid {
  border-color: var(--color-danger);
  background: rgb(220 38 38 / .06);
}

/* Loading */
.dropzone--loading {
  pointer-events: none;
  border-style: solid;
  border-color: var(--color-primary);
}

/* Has files (condensed) */
.dropzone--has-files {
  padding: var(--space-6);
  min-height: auto;
  cursor: default;
  border-style: solid;
}

.dropzone__icon {
  width: 56px;
  height: 56px;
  color: var(--color-text-muted);
  opacity: 0.5;
  transition: opacity var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.dropzone:hover .dropzone__icon,
.dropzone--drag-over .dropzone__icon {
  color: var(--color-primary);
  opacity: 1;
}

.dropzone__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
}

.dropzone__sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.dropzone__or {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.dropzone__constraints {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
  opacity: 0.7;
}

.dropzone__error-msg {
  color: var(--color-danger);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════════════
   FILE ROW (uploaded file list item)
   ══════════════════════════════════════════════════════════════════════════ */

.file-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.file-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.file-row:hover { border-color: var(--color-text-muted); }

.file-row--dragging {
  opacity: 0.5;
  border-style: dashed;
  border-color: var(--color-primary);
}

.file-row--error {
  border-color: var(--color-danger);
  background: rgb(220 38 38 / .04);
}

.file-row__handle {
  cursor: grab;
  color: var(--color-text-muted);
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.file-row:hover .file-row__handle { opacity: 1; }

.file-row__thumb {
  width: 40px;
  height: 48px;
  border-radius: 4px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-row__thumb-icon {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
}

.file-row__info {
  flex: 1;
  min-width: 0;
}

.file-row__name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-row__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.file-row__status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 500;
}

.file-row__status--ready   { color: var(--color-text-muted); }
.file-row__status--loading { color: var(--color-info); }
.file-row__status--done    { color: var(--color-success); }
.file-row__status--error   { color: var(--color-danger); }

.file-row__remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.file-row:hover .file-row__remove { opacity: 1; }
.file-row__remove:hover { background: var(--color-surface-2); color: var(--color-danger); }
.file-row__remove:focus-visible { opacity: 1; outline: none; box-shadow: var(--shadow-focus); }

/* ══════════════════════════════════════════════════════════════════════════
   PDF TOOL WORKSPACE
   ══════════════════════════════════════════════════════════════════════════ */

.tool-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: start;
}

@media (min-width: 1024px) {
  .tool-workspace--pdf {
    grid-template-columns: 1fr 340px;
  }
}

.tool-workspace__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ── Options panel ────────────────────────────────────────────────────────── */
.options-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .options-panel {
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
  }
}

.options-panel__title {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.options-panel__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.options-panel__divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

/* ── Mobile bottom sheet ─────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .bottom-sheet-trigger {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-overlay);
    padding: var(--space-4);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: var(--space-3);
    align-items: center;
  }

  .bottom-sheet-trigger .btn--primary {
    flex: 1;
  }

  .bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-modal);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    border-radius: var(--radius-hero) var(--radius-hero) 0 0;
    box-shadow: var(--shadow-4);
    max-height: 85dvh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform var(--duration-slow) var(--ease-out);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bottom-sheet[aria-hidden="false"] {
    transform: translateY(0);
  }

  @media (prefers-reduced-motion: reduce) {
    .bottom-sheet { transition: none; }
  }

  .bottom-sheet__handle {
    display: flex;
    justify-content: center;
    padding: var(--space-3) 0;
  }

  .bottom-sheet__handle::after {
    content: '';
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-pill);
  }

  .bottom-sheet__content {
    padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 1024px) {
  .bottom-sheet-trigger { display: none; }
}

/* ── Result screen ────────────────────────────────────────────────────────── */
.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-6);
  padding: var(--space-12) var(--space-4);
}

.result-screen__success-icon {
  width: 64px;
  height: 64px;
  color: var(--color-success);
}

.result-screen__title {
  font-size: 1.5rem;
  font-weight: 700;
}

.result-screen__meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

.result-screen__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
}

.result-screen__related {
  width: 100%;
  max-width: 760px;
  text-align: left;
}

.result-screen__related-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
}

.result-screen__related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}

/* ══════════════════════════════════════════════════════════════════════════
   UTILITY TOOL WORKSPACE
   ══════════════════════════════════════════════════════════════════════════ */

.utility-workspace {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.utility-workspace__panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 1024px) {
  .utility-workspace__panels {
    grid-template-columns: 1fr 1fr;
  }
}

.utility-panel {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.utility-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.utility-panel__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}

.utility-panel__counter {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.utility-panel__body {
  flex: 1;
  position: relative;
}

.utility-panel__textarea {
  width: 100%;
  height: 100%;
  min-height: 260px;
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  resize: none;
  border: none;
  background: transparent;
  color: var(--color-text);
  outline: none;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.tool-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  flex-wrap: wrap;
}

.tool-toolbar__divider {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin: 0 var(--space-1);
}

.tool-toolbar__live-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-left: auto;
}

/* ══════════════════════════════════════════════════════════════════════════
   IMAGE TOOL WORKSPACE
   ══════════════════════════════════════════════════════════════════════════ */

.image-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: start;
}

@media (min-width: 1024px) {
  .image-workspace {
    grid-template-columns: 1fr 300px;
  }
}

.canvas-stage {
  background: repeating-conic-gradient(#e2e8f0 0% 25%, #f8fafc 0% 50%)
    0 0 / 24px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  position: relative;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .canvas-stage {
  background: repeating-conic-gradient(#1a213f 0% 25%, #18213f 0% 50%)
    0 0 / 24px 24px;
}

.canvas-stage__canvas {
  max-width: 100%;
  max-height: 560px;
  object-fit: contain;
}

.canvas-stage__controls {
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-3);
  display: flex;
  gap: var(--space-1);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: 3px;
}

/* ── Before/After slider ──────────────────────────────────────────────────── */
.before-after {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-card);
  cursor: ew-resize;
  user-select: none;
}

.before-after__before,
.before-after__after {
  position: absolute;
  inset: 0;
}

.before-after__before {
  overflow: hidden;
}

.before-after__before img,
.before-after__after img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.before-after__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .3);
  z-index: 10;
  cursor: ew-resize;
}

.before-after__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
}

.before-after__label {
  position: absolute;
  top: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  background: rgb(0 0 0 / .5);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.before-after__label--before { left: var(--space-3); }
.before-after__label--after  { right: var(--space-3); }

/* ══════════════════════════════════════════════════════════════════════════
   STEPPER ("1 Upload, 2 Options, 3 Download")
   ══════════════════════════════════════════════════════════════════════════ */

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.stepper::-webkit-scrollbar { display: none; }

.stepper__step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.stepper__step:not(:last-child)::after {
  content: '';
  display: block;
  width: 32px;
  height: 1px;
  background: var(--color-border);
  margin: 0 var(--space-2);
  flex-shrink: 0;
}

.stepper__number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.stepper__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-out);
}

/* Active step */
.stepper__step--active .stepper__number {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
}

.stepper__step--active .stepper__label {
  color: var(--color-text);
  font-weight: 600;
}

/* Completed step */
.stepper__step--done .stepper__number {
  background: var(--color-success);
  border-color: transparent;
  color: #fff;
}

.stepper__step--done .stepper__label {
  color: var(--color-text-muted);
}

/* ══════════════════════════════════════════════════════════════════════════
   TOOL PAGE HEADER
   ══════════════════════════════════════════════════════════════════════════ */

.tool-page-header {
  padding: var(--space-8) 0 var(--space-6);
}

.tool-page-header__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.tool-page-header__top {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.tool-page-header__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-page-header__icon svg {
  width: 28px;
  height: 28px;
}

.tool-page-header__title-group { flex: 1; min-width: 0; }

.tool-page-header__title {
  font-size: clamp(1.5rem, 2.5vw + 0.5rem, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: var(--line-tight);
}

.tool-page-header__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: var(--space-1) 0 0;
  max-width: 60ch;
}

.tool-page-header__privacy-note {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-success);
  background: rgb(22 163 74 / .1);
  padding: 3px var(--space-2);
  border-radius: var(--radius-pill);
  border: 1px solid rgb(22 163 74 / .2);
}
