/* Multiple Pages Per Sheet - styles */

:root {
  --accent-1: #C2410C;
  --accent-2: #FB923C;
  --ink: #1E1B14;
  --ink-soft: #78716C;
  --border: #E7E5E4;
  --bg-soft: #FFF7ED;
  --danger: #DC2626;
  --success: #059669;
}

* { box-sizing: border-box; }

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

.app-wrapper {
  max-width: 960px;
  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(194, 65, 12, 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 #FED7AA;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: #9A3412;
  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 #FED7AA;
  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: #FFEDD5;
}
.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: #A8A29E; }

.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 280px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 760px) {
  .configure-layout { grid-template-columns: 1fr; }
}

.preview-panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 800;
}
.preview-header-sub { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }

.nup-sheet-wrap { display: flex; justify-content: center; }
.nup-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(0,0,0,0.14);
  border-radius: 2px;
}
.nup-grid {
  position: absolute;
  display: grid;
}
.nup-cell {
  position: relative;
  overflow: hidden;
  background: #fff;
}
.nup-cell.has-border { outline: 1px solid #D6D3D1; outline-offset: -1px; }
.nup-cell img {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
}
.nup-cell-empty {
  background: repeating-linear-gradient(135deg, #F5F5F4, #F5F5F4 6px, #FAFAF9 6px, #FAFAF9 12px);
}
.nup-cell-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #D6D3D1;
  font-size: 11px;
}

.preview-caption {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}
.preview-caption .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; color: var(--ink); }
.preview-meta-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.preview-meta-row .k { color: var(--ink-soft); }
.preview-meta-row .v { font-weight: 700; }
.preview-meta-total { margin-top: 4px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12.5px; }

.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.file-chip .file-chip-icon { color: var(--accent-1); flex: none; width: 15px; height: 15px; }
.file-chip .file-chip-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; color: var(--ink); }
.file-chip .file-chip-pages { flex: none; color: var(--ink-soft); font-weight: 600; }
.file-chip .file-chip-remove {
  flex: none;
  background: none;
  border: none;
  color: #B0958A;
  cursor: pointer;
  padding: 2px;
  display: flex;
  line-height: 0;
}
.file-chip .file-chip-remove:hover { color: var(--danger); }
.file-chip .file-chip-remove svg { width: 14px; height: 14px; }

.btn-add-file {
  width: 100%;
  margin-top: 12px;
  background: #fff;
  border: 1.5px dashed #FDBA74;
  color: var(--accent-1);
  padding: 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-add-file svg { width: 15px; height: 15px; }
.btn-add-file:hover { background: var(--bg-soft); }
.btn-add-file:disabled { opacity: 0.6; cursor: default; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-1);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-top: 10px;
}

.options-panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.options-panel .section-label { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); margin-bottom: 8px; }

.persheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.persheet-option { display: none; }
.persheet-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 4px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  transition: all 0.15s ease;
  user-select: none;
}
.persheet-tile:hover { border-color: #FDBA74; }
.persheet-option:checked + .persheet-tile {
  border-color: var(--accent-1);
  background: linear-gradient(135deg, rgba(194,65,12,0.08), rgba(251,146,60,0.08));
  box-shadow: 0 0 0 3px rgba(194,65,12,0.12);
  color: var(--accent-1);
}
.persheet-option:focus-visible + .persheet-tile { outline: 2px solid var(--accent-1); outline-offset: 2px; }

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.option-row.sub-row { padding-left: 2px; }
.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: #D6D3D1; 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(194,65,12,0.3); }

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

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

.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: #FFF7ED; 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: #FFF7ED; 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;
}
.quality-pill.raster { background: #FEF3C7; color: #92400E; }

.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; }
