/* ============================================================
   Product CoA Widget — Premium card with PDF preview & lightbox
   ============================================================ */

.ppv-coa-wrapper {
  --ppv-coa-radius: 16px;
  --ppv-coa-gap: 20px;
  --ppv-coa-border: #e5e7eb;
  --ppv-coa-text: #0F172A;
  --ppv-coa-muted: #6B7280;
  --ppv-coa-accent: #16A34A;
  --ppv-coa-frame-bg: #111827;
  --ppv-coa-tab-bg: #F3F4F6;
  --ppv-coa-tab-active: #0F172A;

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ppv-coa-text);
  -webkit-font-smoothing: antialiased;
}

.ppv-coa-wrapper *,
.ppv-coa-wrapper *::before,
.ppv-coa-wrapper *::after {
  box-sizing: border-box;
}

/* ── Header ────────────────────────────────────────────────── */
.ppv-coa-header {
  margin-bottom: 24px;
}

.ppv-coa-title {
  margin: 0 0 6px;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.ppv-coa-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--ppv-coa-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Card ─────────────────────────────────────────────────── */
.ppv-coa-card {
  background: #fff;
  border: 1px solid var(--ppv-coa-border);
  border-radius: var(--ppv-coa-radius);
  padding: 28px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02), 0 6px 24px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.3s ease;
}

.ppv-coa-card:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.03), 0 12px 32px rgba(0, 0, 0, 0.06);
}

/* ── Variant Tabs ─────────────────────────────────────────── */
.ppv-coa-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--ppv-coa-border);
}

.ppv-coa-tab {
  appearance: none;
  -webkit-appearance: none;
  background: var(--ppv-coa-tab-bg);
  color: var(--ppv-coa-text);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
}

.ppv-coa-tab:hover {
  background: #e5e7eb;
}

.ppv-coa-tab.is-active {
  background: var(--ppv-coa-tab-active);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.ppv-coa-tab:focus-visible {
  outline: 2px solid var(--ppv-coa-accent);
  outline-offset: 2px;
}

/* ── Panel ────────────────────────────────────────────────── */
.ppv-coa-panel {
  display: none;
  animation: ppvCoAFadeIn 0.3s ease both;
}

.ppv-coa-panel.is-active {
  display: block;
}

@keyframes ppvCoAFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Summary (Purity + Meta) ──────────────────────────────── */
.ppv-coa-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.ppv-coa-purity {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ppv-coa-selected-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ppv-coa-muted);
}

.ppv-coa-purity-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 2px 0;
}

.ppv-coa-purity-value {
  font-size: clamp(40px, 5vw, 56px);
  font-weight: 800;
  line-height: 1;
  color: var(--ppv-coa-accent);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.ppv-coa-purity-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--ppv-coa-accent);
  margin-top: 2px;
}

.ppv-coa-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
  min-width: 140px;
}

.ppv-coa-meta-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
  justify-content: flex-end;
}

.ppv-coa-meta-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ppv-coa-muted);
}

.ppv-coa-meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--ppv-coa-text);
}

/* ── PDF Preview Frame ────────────────────────────────────── */
.ppv-coa-preview {
  position: relative;
}

.ppv-coa-preview-frame {
  position: relative;
  background: var(--ppv-coa-frame-bg);
  border-radius: 12px;
  overflow: hidden;
  height: 480px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
}

.ppv-coa-preview-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
}

.ppv-coa-preview-expand {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.85);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0;
}

.ppv-coa-preview-expand:hover {
  background: rgba(17, 24, 39, 0.95);
  transform: scale(1.05);
}

.ppv-coa-preview-expand svg {
  width: 16px;
  height: 16px;
}

/* ── Actions Row ──────────────────────────────────────────── */
.ppv-coa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.ppv-coa-view-full {
  appearance: none;
  background: none;
  border: none;
  color: var(--ppv-coa-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  transition: color 0.2s ease, text-decoration-thickness 0.2s ease;
}

.ppv-coa-view-full:hover {
  text-decoration-thickness: 2px;
}

.ppv-coa-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--ppv-coa-tab-active);
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.ppv-coa-download:hover {
  background: #1e293b;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.22);
  color: #fff;
  text-decoration: none;
}

.ppv-coa-download:active {
  transform: translateY(0);
}

.ppv-coa-download svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Empty state ──────────────────────────────────────────── */
.ppv-coa-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 24px;
  gap: 14px;
}

.ppv-coa-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ppv-coa-muted);
}

.ppv-coa-empty-icon svg {
  width: 28px;
  height: 28px;
}

.ppv-coa-empty-text {
  color: var(--ppv-coa-muted);
  font-size: 14px;
  margin: 0;
}

.ppv-coa-no-url {
  text-align: center;
  color: var(--ppv-coa-muted);
  padding: 32px;
  margin: 0;
}

/* ── Lightbox ─────────────────────────────────────────────── */
.ppv-coa-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: ppvCoAFadeBg 0.2s ease both;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ppv-coa-lightbox.is-open {
  display: flex;
}

@keyframes ppvCoAFadeBg {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ppv-coa-lightbox-inner {
  position: relative;
  width: 100%;
  max-width: 1000px;
  height: 90vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: ppvCoAScaleIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ppvCoAScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.ppv-coa-lightbox-inner iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
}

.ppv-coa-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 2;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ppv-coa-lightbox-close:hover {
  background: rgba(17, 24, 39, 1);
  transform: rotate(90deg);
}

.ppv-coa-lightbox-close svg {
  width: 18px;
  height: 18px;
}

.ppv-coa-lightbox-title {
  position: absolute;
  top: 14px;
  left: 20px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  z-index: 2;
  max-width: calc(100% - 80px);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ppv-coa-locked {
  overflow: hidden;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .ppv-coa-card {
    padding: 20px;
  }

  .ppv-coa-summary {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
  }

  .ppv-coa-meta {
    text-align: left;
    min-width: 0;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 16px;
  }

  .ppv-coa-meta-row {
    justify-content: flex-start;
  }

  .ppv-coa-preview-frame {
    height: 360px;
  }

  .ppv-coa-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .ppv-coa-tabs::-webkit-scrollbar {
    display: none;
  }

  .ppv-coa-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ppv-coa-download {
    justify-content: center;
  }

  .ppv-coa-view-full {
    text-align: center;
  }

  .ppv-coa-lightbox {
    padding: 8px;
  }

  .ppv-coa-lightbox-inner {
    height: calc(100vh - 16px);
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  .ppv-coa-card {
    padding: 16px;
    border-radius: 14px;
  }

  .ppv-coa-preview-frame {
    height: 320px;
  }

  .ppv-coa-title {
    font-size: 22px;
  }

  .ppv-coa-subtitle {
    font-size: 13px;
  }

  .ppv-coa-purity-value {
    font-size: 36px;
  }

  .ppv-coa-tab {
    padding: 7px 13px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ppv-coa-panel,
  .ppv-coa-lightbox,
  .ppv-coa-lightbox-inner {
    animation: none;
  }

  .ppv-coa-tab,
  .ppv-coa-download,
  .ppv-coa-preview-expand,
  .ppv-coa-lightbox-close {
    transition: none;
  }
}
