/* ──────────────────────────────────────────────────────────────────────────
 * PreviewModal — fullscreen print-preview overlay.
 *
 * Z-index 1000 to sit above the bottom sheet (800), FAB (700), and any
 * canvas-area floating UI (export-toast, app-toast at 12-13). Only the
 * photo-pre-editor goes higher.
 *
 * Body-scroll lock is applied via the `has-preview-modal` class to prevent
 * pan-while-zoomed on touch devices.
 * ────────────────────────────────────────────────────────────────────────── */

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 29, 35, 0.62);
  border: none;
  padding: 0;
  cursor: pointer;
  animation: pm-backdrop-in 0.18s ease-out;
}

@keyframes pm-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.preview-modal__panel {
  position: relative;
  z-index: 1;
  background: var(--brand-cream);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  width: min(720px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pm-panel-in 0.22s cubic-bezier(0.32, 0.72, 0.16, 1);
}

@keyframes pm-panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.preview-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.preview-modal__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.preview-modal__close {
  background: transparent;
  border: none;
  padding: 0.4rem 0.55rem;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, color 0.12s ease;
}

.preview-modal__close:hover {
  background: var(--brand-pink-soft);
  color: var(--brand-pink-strong);
}

.preview-modal__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-pink-tint);
  padding: 1.5rem;
  min-height: 280px;
  /* Subtle checkerboard so transparent PNG areas read as transparent
   * instead of looking like white-on-white. */
  background-image:
    linear-gradient(45deg, rgba(0, 0, 0, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.04) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.preview-modal__image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  background: #fff;
}

.preview-modal__loading,
.preview-modal__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

.preview-modal__error {
  color: #b91c1c;
}

.preview-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.2rem;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.preview-modal__hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
}

.preview-modal__actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.preview-modal__btn {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  border: 1.5px solid transparent;
}

.preview-modal__btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.preview-modal__btn--ghost:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.preview-modal__btn--primary {
  background: var(--brand-pink);
  color: #fff;
  border-color: var(--brand-pink);
  box-shadow: 0 6px 12px -3px rgba(236, 72, 153, 0.5);
}

.preview-modal__btn--primary:hover:not(:disabled) {
  background: var(--brand-pink-strong);
  border-color: var(--brand-pink-strong);
  transform: translateY(-1px);
}

.preview-modal__btn--primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

body.has-preview-modal {
  overflow: hidden;
  touch-action: none;
}

/* Mobile — full-bleed panel, footer wraps if needed. */
@media (max-width: 600px) {
  .preview-modal {
    padding: 0.5rem;
  }
  .preview-modal__panel {
    max-height: 96vh;
  }
  .preview-modal__footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .preview-modal__actions {
    width: 100%;
  }
  .preview-modal__btn {
    flex: 1;
    text-align: center;
  }
  .preview-modal__hint {
    text-align: center;
  }
}
