/* ============================================================
   Advanced PDF Optimizer — Frontend Stylesheet
   ============================================================ */

.apo-tool-wrap {
  --apo-primary:   #6366f1;
  --apo-success:   #22c55e;
  --apo-danger:    #ef4444;
  --apo-warning:   #f59e0b;
  --apo-muted:     #6b7280;
  --apo-border:    #e5e7eb;
  --apo-surface:   #f9fafb;
  --apo-text:      #111827;
  --apo-radius:    12px;
  --apo-transition: all .18s ease;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--apo-text);
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
  box-sizing: border-box;
}

.apo-tool-wrap *, .apo-tool-wrap *::before, .apo-tool-wrap *::after {
  box-sizing: border-box;
}

/* ── Dropzone ──────────────────────────────────────────── */
.apo-dropzone {
  border: 2px dashed var(--apo-border);
  border-radius: var(--apo-radius);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--apo-transition);
  background: var(--apo-surface);
  outline: none;
}
.apo-dropzone:hover,
.apo-dropzone:focus,
.apo-dropzone.is-over {
  border-color: var(--apo-primary);
  background: rgba(99,102,241,.04);
}
.apo-dropzone__icon { font-size: 3.2rem; margin-bottom: 16px; display: block; }
.apo-dropzone__title { font-size: 1.1rem; font-weight: 700; color: var(--apo-text); margin-bottom: 8px; }
.apo-dropzone__sub { font-size: .875rem; color: var(--apo-muted); }
.apo-dropzone__btn {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 24px;
  background: var(--apo-primary);
  color: #fff;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--apo-transition);
  border: none;
}
.apo-dropzone__btn:hover { opacity: .9; }

/* ── File selected card ────────────────────────────────── */
.apo-file-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--apo-surface);
  border: 1px solid var(--apo-border);
  border-radius: 10px;
  margin-bottom: 20px;
}
.apo-file-card__icon { font-size: 2.2rem; flex-shrink: 0; }
.apo-file-card__info { flex: 1; overflow: hidden; }
.apo-file-card__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apo-file-card__size { font-size: .8rem; color: var(--apo-muted); margin-top: 2px; }
.apo-file-card__remove {
  background: transparent;
  border: 1px solid var(--apo-border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: .78rem;
  color: var(--apo-muted);
  transition: var(--apo-transition);
  flex-shrink: 0;
}
.apo-file-card__remove:hover { border-color: var(--apo-danger); color: var(--apo-danger); }

/* ── Level selector ────────────────────────────────────── */
.apo-level-group { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.apo-level-radio { display: none; }
.apo-level-label {
  flex: 1; min-width: 100px;
  border: 2px solid var(--apo-border);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: var(--apo-transition);
  user-select: none;
}
.apo-level-label__icon { font-size: 1.4rem; display: block; margin-bottom: 4px; }
.apo-level-label__title { font-size: .84rem; font-weight: 700; display: block; }
.apo-level-label__desc { font-size: .72rem; color: var(--apo-muted); display: block; margin-top: 2px; }
.apo-level-radio:checked + .apo-level-label {
  border-color: var(--apo-primary);
  background: rgba(99,102,241,.06);
}
.apo-level-label:hover { border-color: var(--apo-primary); }

/* ── Primary button ────────────────────────────────────── */
.apo-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--apo-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--apo-transition);
}
.apo-btn-primary:hover:not(:disabled) { opacity: .92; transform: translateY(-1px); }
.apo-btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ── Progress ──────────────────────────────────────────── */
.apo-progress {
  text-align: center;
  padding: 32px 0;
}
.apo-progress__ring {
  width: 64px; height: 64px;
  border: 4px solid rgba(99,102,241,.18);
  border-top-color: var(--apo-primary);
  border-radius: 50%;
  animation: apo-fe-spin .8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes apo-fe-spin { to { transform: rotate(360deg); } }
.apo-progress__label { font-size: .95rem; font-weight: 600; margin-bottom: 6px; }
.apo-progress__note { font-size: .78rem; color: var(--apo-muted); }
.apo-progress-bar { height: 6px; background: rgba(99,102,241,.12); border-radius: 100px; margin: 12px 0; overflow: hidden; }
.apo-progress-bar__fill {
  height: 100%;
  background: var(--apo-primary);
  width: 0;
  border-radius: 100px;
  transition: width .4s;
}

/* ── Result ────────────────────────────────────────────── */
.apo-result { text-align: center; }
.apo-result__check { font-size: 3rem; margin-bottom: 8px; display: block; }
.apo-result__title { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }
.apo-result__stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 18px;
  background: var(--apo-surface);
  border: 1px solid var(--apo-border);
  border-radius: 10px;
  flex-wrap: wrap;
}
.apo-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.apo-stat__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--apo-muted); }
.apo-stat__val { font-size: 1.2rem; font-weight: 700; }
.apo-stat__val--savings { color: var(--apo-success); }
.apo-result__arrow { font-size: 1.3rem; color: var(--apo-muted); }

.apo-result__btn-dl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--apo-success);
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
  transition: var(--apo-transition);
}
.apo-result__btn-dl:hover { opacity: .92; color: #fff; transform: translateY(-1px); }
.apo-result__btn-dl.is-expired { opacity: .4; pointer-events: none; }

.apo-result__actions { display: flex; gap: 8px; margin-top: 10px; }
.apo-result__btn-another,
.apo-result__btn-delete {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--apo-transition);
  border: 1px solid var(--apo-border);
  background: transparent;
}
.apo-result__btn-another:hover { border-color: var(--apo-primary); color: var(--apo-primary); }
.apo-result__btn-delete { border-color: rgba(239,68,68,.3); color: var(--apo-danger); }
.apo-result__btn-delete:hover { background: rgba(239,68,68,.06); }
.apo-result__btn-delete:disabled { opacity: .5; cursor: default; }

/* Expiry bar */
.apo-expiry-bar {
  background: var(--apo-surface);
  border: 1px solid var(--apo-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .8rem;
  color: var(--apo-muted);
  margin-top: 14px;
}
.apo-expiry-bar__top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.apo-expiry-bar__top strong { color: var(--apo-text); font-variant-numeric: tabular-nums; }
.apo-expiry-bar__downloaded { color: var(--apo-success); font-weight: 700; font-size: .78rem; display: none; }
.apo-expiry-track { height: 4px; background: rgba(0,0,0,.07); border-radius: 100px; overflow: hidden; }
.apo-expiry-fill {
  height: 100%;
  width: 100%;
  background: var(--apo-primary);
  border-radius: 100px;
  transition: width 1s linear, background .5s;
}

.apo-result__deleted-msg {
  text-align: center;
  font-size: .875rem;
  font-weight: 600;
  color: var(--apo-success);
  padding: 10px;
  background: rgba(34,197,94,.06);
  border-radius: 8px;
  margin-top: 12px;
  display: none;
}

/* ── Error ─────────────────────────────────────────────── */
.apo-error {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 10px;
  font-size: .875rem;
  color: #b91c1c;
}
.apo-error__icon { flex-shrink: 0; font-size: 1.2rem; }
.apo-error__msg { flex: 1; }
.apo-error__dismiss {
  background: transparent; border: none;
  cursor: pointer; color: #b91c1c; font-size: 1rem; padding: 0;
}

/* ── Bulk file list ────────────────────────────────────── */
.apo-bulk-list { list-style: none; padding: 0; margin: 16px 0 0; }
.apo-bulk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--apo-border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: .875rem;
  background: var(--apo-surface);
}
.apo-bulk-item__name  { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apo-bulk-item__size  { color: var(--apo-muted); font-size: .8rem; }
.apo-bulk-item__status { font-size: .78rem; font-weight: 700; }
.apo-bulk-item__status--pending { color: var(--apo-muted); }
.apo-bulk-item__status--ok      { color: var(--apo-success); }
.apo-bulk-item__status--error   { color: var(--apo-danger);  }
.apo-bulk-item__bar { width: 60px; height: 4px; background: var(--apo-border); border-radius: 100px; overflow: hidden; }
.apo-bulk-item__bar-fill { height: 100%; background: var(--apo-primary); width: 0; transition: width .4s; }

/* ── Access denied ─────────────────────────────────────── */
.apo-access-denied {
  padding: 24px;
  text-align: center;
  color: var(--apo-muted);
  background: var(--apo-surface);
  border: 1px solid var(--apo-border);
  border-radius: var(--apo-radius);
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 520px) {
  .apo-level-group { flex-direction: column; }
  .apo-result__stats { gap: 10px; }
}
