/* ══════════════════════════════════════════════════════════
   PDFMaster — Universal Thank You & Download Popup Modal
   ══════════════════════════════════════════════════════════
   Redesigned to match the clean, clutter-free, responsive
   aesthetic of the signature resultsCard in rotate-pdf.
   Scoped tokens inherit from host pages while preserving
   perfect contrast, typography, and theme parity across
   both light and dark modes.
   ══════════════════════════════════════════════════════════ */

.pdfm-popup-overlay {
  /* Surfaces & Neutrals — inherit host page where possible, fallback gracefully */
  --pdfm-bg: var(--bg, #f8f7f5);
  --pdfm-surface: var(--surface, #ffffff);
  --pdfm-surface-2: var(--surface-2, #f2f1ef);
  --pdfm-surface-3: var(--surface-3, #eae9e6);
  --pdfm-border: var(--border, #e4e2de);
  --pdfm-border-focus: var(--border-focus, #c8c5be);
  --pdfm-text: var(--text, #1a1917);
  --pdfm-text-2: var(--text-2, #4a4845);
  --pdfm-text-3: var(--text-3, #7a7875);
  --pdfm-radius: var(--radius, 12px);
  --pdfm-radius-sm: var(--radius-sm, 8px);
  --pdfm-radius-lg: var(--radius-lg, 20px);
  --pdfm-radius-full: var(--radius-full, 9999px);

  /* Signature resultsCard Green */
  --pdfm-success-green: #10b981;
  --pdfm-success-green-dark: #059669;
  --pdfm-success-bg: rgba(16, 185, 129, 0.12);
  --pdfm-success-glow: rgba(16, 185, 129, 0.25);

  /* Primary Brand Accent */
  --pdfm-accent: var(--accent, #e8372a);
  --pdfm-accent-dark: var(--accent-dark, #c42d21);
  --pdfm-accent-glow: rgba(232, 55, 42, 0.32);

  /* Modal Backdrop */
  --pdfm-overlay: var(--modal-overlay, rgba(15, 15, 15, 0.65));
  --pdfm-font-heading: var(--font-heading, "Sora", sans-serif);
  --pdfm-font-body: var(--font-body, "DM Sans", sans-serif);

  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 16px;
  box-sizing: border-box;
  background: var(--pdfm-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

[data-theme="dark"] .pdfm-popup-overlay,
.pdfm-popup-overlay[data-theme="dark"] {
  --pdfm-bg: var(--bg, #111110);
  --pdfm-surface: var(--surface, #1c1b1a);
  --pdfm-surface-2: var(--surface-2, #252422);
  --pdfm-surface-3: var(--surface-3, #2e2c2a);
  --pdfm-border: var(--border, #333230);
  --pdfm-border-focus: var(--border-focus, #4a4845);
  --pdfm-text: var(--text, #f0ede8);
  --pdfm-text-2: var(--text-2, #b5b0a8);
  --pdfm-text-3: var(--text-3, #7a7875);
  --pdfm-overlay: var(--modal-overlay, rgba(0, 0, 0, 0.82));
  --pdfm-success-bg: rgba(16, 185, 129, 0.16);
  --pdfm-accent-glow: rgba(232, 55, 42, 0.45);
}

.pdfm-popup-overlay.show {
  display: flex;
  opacity: 1;
  visibility: visible;
}

/* ── Modal box (matches .results-card) ───────────────────── */

.pdfm-popup-box {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 36px 32px 24px;
  text-align: center;
  background: var(--pdfm-surface);
  border: 2px solid var(--pdfm-success-green);
  border-radius: var(--pdfm-radius-lg);
  box-shadow:
    0 20px 50px rgba(16, 185, 129, 0.14),
    0 24px 64px rgba(0, 0, 0, 0.22);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .pdfm-popup-box {
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.7),
    0 0 35px rgba(16, 185, 129, 0.15);
}

.pdfm-popup-overlay.show .pdfm-popup-box {
  transform: scale(1) translateY(0);
}

.pdfm-popup-box::-webkit-scrollbar {
  width: 5px;
}
.pdfm-popup-box::-webkit-scrollbar-track {
  background: transparent;
}
.pdfm-popup-box::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.25);
  border-radius: 4px;
}

/* ── Close button ────────────────────────────────────────── */

.pdfm-popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--pdfm-border);
  background: var(--pdfm-surface-2);
  color: var(--pdfm-text-2);
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.pdfm-popup-close:hover {
  background: var(--pdfm-surface-3);
  color: var(--pdfm-text);
  border-color: var(--pdfm-border-focus);
  transform: rotate(90deg);
}

/* ── Success Icon Badge (64px circle checkmark) ─────────── */

.pdfm-results-icon,
.pdfm-popup-icon-wrap {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--pdfm-success-bg);
  color: var(--pdfm-success-green);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.pdfm-popup-overlay.show .pdfm-results-icon {
  animation: pdfmIconPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes pdfmIconPop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Title & description ─────────────────────────────────── */

.pdfm-results-title,
.pdfm-popup-title {
  margin: 0 0 8px;
  font-family: var(--pdfm-font-heading);
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.25;
  color: var(--pdfm-text);
  letter-spacing: -0.02em;
}

.pdfm-results-title span,
.pdfm-popup-title span {
  color: var(--pdfm-accent);
}

.pdfm-results-sub,
.pdfm-popup-desc {
  margin: 0 auto 22px;
  max-width: 480px;
  font-family: var(--pdfm-font-body);
  font-size: 0.93rem;
  line-height: 1.5;
  color: var(--pdfm-text-2);
}

.pdfm-results-sub strong,
.pdfm-popup-desc strong {
  color: var(--pdfm-text);
  font-weight: 700;
}

/* ── Signature Stats Capsule (matches .results-stats) ────── */

.pdfm-results-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  margin: 0 auto 24px;
  padding: 14px 20px;
  background: var(--pdfm-surface-2);
  border: 1px solid var(--pdfm-border);
  border-radius: var(--pdfm-radius);
  box-sizing: border-box;
}

.pdfm-stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  padding: 0 6px;
}

.pdfm-stat-label {
  color: var(--pdfm-text-3);
  font-family: var(--pdfm-font-body);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  white-space: nowrap;
}

.pdfm-stat-val,
.pdfm-popup-file-name,
.pdfm-popup-file-details {
  font-family: var(--pdfm-font-body);
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--pdfm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.3;
}

.pdfm-stat-speed {
  color: var(--pdfm-success-green);
}

.pdfm-results-stat-divider {
  width: 1px;
  height: 28px;
  background: var(--pdfm-border);
  flex-shrink: 0;
  margin: 0 4px;
}

/* ── Notice / Warning Banner ─────────────────────────────── */

.pdfm-popup-notice {
  margin: 0 auto 20px;
  max-width: 500px;
  padding: 12px 18px;
  border-radius: var(--pdfm-radius);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #b45309;
  font-family: var(--pdfm-font-body);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: left;
  box-sizing: border-box;
}

[data-theme="dark"] .pdfm-popup-notice {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.pdfm-popup-notice strong {
  color: inherit;
  font-weight: 700;
}

/* ── Action buttons (matches .results-actions) ───────────── */

.pdfm-results-actions,
.pdfm-popup-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.pdfm-btn-primary,
.pdfm-popup-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 28px;
  font-family: var(--pdfm-font-body);
  font-weight: 600;
  font-size: 0.96rem;
  color: #ffffff;
  background: var(--pdfm-accent);
  border: none;
  border-radius: var(--pdfm-radius-full);
  cursor: pointer;
  box-shadow: 0 4px 14px var(--pdfm-accent-glow);
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.pdfm-btn-primary:hover,
.pdfm-popup-download-btn:hover {
  background: var(--pdfm-accent-dark);
  box-shadow: 0 6px 20px var(--pdfm-accent-glow);
  transform: translateY(-1px);
}

.pdfm-btn-primary.is-downloaded,
.pdfm-popup-download-btn.is-downloaded {
  background: var(--pdfm-success-green);
  box-shadow: 0 4px 14px var(--pdfm-success-glow);
}

.pdfm-btn-primary.is-downloaded:hover,
.pdfm-popup-download-btn.is-downloaded:hover {
  background: var(--pdfm-success-green-dark);
  box-shadow: 0 6px 20px var(--pdfm-success-glow);
}

.pdfm-btn-secondary,
.pdfm-popup-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  font-family: var(--pdfm-font-body);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--pdfm-text-2);
  background: var(--pdfm-surface-2);
  border: 1px solid var(--pdfm-border);
  border-radius: var(--pdfm-radius-full);
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}

.pdfm-btn-secondary:hover,
.pdfm-popup-secondary-btn:hover {
  background: var(--pdfm-surface-3);
  color: var(--pdfm-text);
  border-color: var(--pdfm-text-3);
}

/* ── Bookmark Button (Prominent & Clear) ─────────────────── */

.pdfm-bookmark-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  width: 100%;
}

.pdfm-bookmark-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 22px;
  background: var(--pdfm-surface-2);
  border: 1.5px solid var(--pdfm-border);
  border-radius: var(--pdfm-radius-full);
  font-family: var(--pdfm-font-body);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--pdfm-text);
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.pdfm-bookmark-btn:hover {
  background: var(--pdfm-surface-3);
  border-color: #f59e0b;
  color: var(--pdfm-text);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.18);
}

.pdfm-bookmark-btn svg {
  flex-shrink: 0;
  color: #f59e0b;
}

/* ── Privacy Guarantee (Dedicated clean line) ────────────── */

.pdfm-privacy-guarantee {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--pdfm-font-body);
  font-size: 0.77rem;
  line-height: 1.4;
  color: var(--pdfm-text-3);
  margin-bottom: 12px;
}

.pdfm-privacy-guarantee svg {
  flex-shrink: 0;
  color: var(--pdfm-success-green);
}

/* ── TrustBox widget ─────────────────────────────────────── */

.pdfm-popup-trustpilot {
  width: 100%;
  min-height: 44px;
  max-height: 48px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pdfm-popup-trustpilot .trustpilot-widget {
  width: 100%;
  min-height: 44px;
}

/* ══════════════════════════════════════════════════════════
   Legacy on-page hooks (used by merge-pdf.html / photo-to-
   pdf.html buttons outside the modal — kept as-is on purpose)
   ══════════════════════════════════════════════════════════ */

.btn-download-ready {
  background: #16a34a !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35) !important;
}

.btn-download-ready:hover {
  background: #15803d !important;
  box-shadow: 0 8px 22px rgba(22, 163, 74, 0.45) !important;
  transform: translateY(-2px);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--primary, #d1301f);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  vertical-align: middle;
}

.link-btn:hover {
  color: var(--primary-dark, #b8271a);
}

/* ══════════════════════════════════════════════════════════
   Responsive (down to 320px screen width)
   ══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .pdfm-popup-overlay {
    padding: 12px;
  }

  .pdfm-popup-box {
    padding: 24px 16px 18px;
    border-radius: 18px;
    max-width: 100%;
  }

  .pdfm-popup-close {
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
  }

  .pdfm-results-icon,
  .pdfm-popup-icon-wrap {
    width: 52px;
    height: 52px;
    margin-bottom: 12px;
  }

  .pdfm-results-icon svg {
    width: 26px;
    height: 26px;
  }

  .pdfm-results-title,
  .pdfm-popup-title {
    font-size: 1.35rem;
  }

  .pdfm-results-sub,
  .pdfm-popup-desc {
    font-size: 0.88rem;
    margin-bottom: 18px;
  }

  .pdfm-results-stats {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 20px;
  }

  .pdfm-results-stats .pdfm-stat-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .pdfm-stat-val,
  .pdfm-popup-file-name,
  .pdfm-popup-file-details {
    max-width: 180px;
    text-align: right;
  }

  .pdfm-results-stat-divider {
    display: block !important;
    width: 100% !important;
    height: 1px !important;
    background: var(--pdfm-border) !important;
  }

  .pdfm-results-actions,
  .pdfm-popup-btns {
    flex-direction: column;
    width: 100%;
    gap: 10px;
    margin-bottom: 14px;
  }

  .pdfm-results-actions button,
  .pdfm-popup-btns button {
    width: 100%;
    justify-content: center;
    padding: 13px 20px;
  }

  .pdfm-bookmark-row {
    width: 100%;
    margin-bottom: 12px;
  }

  .pdfm-bookmark-btn {
    width: 100%;
    justify-content: center;
    padding: 11px 18px;
    font-size: 0.88rem;
  }

  .pdfm-privacy-guarantee {
    font-size: 0.74rem;
    margin-bottom: 8px;
    text-align: center;
  }
}

@media (max-width: 360px) {
  .pdfm-stat-val,
  .pdfm-popup-file-name,
  .pdfm-popup-file-details {
    max-width: 140px;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .pdfm-popup-overlay,
  .pdfm-popup-box,
  .pdfm-popup-close,
  .pdfm-btn-primary,
  .pdfm-popup-download-btn,
  .pdfm-btn-secondary,
  .pdfm-popup-secondary-btn,
  .pdfm-bookmark-link,
  .pdfm-bookmark-btn {
    transition: none !important;
    animation: none !important;
  }
}
