/* ================================================
   COA Manager v3.1 — Frontend CSS
   ================================================ */

/* ---- Grid ---- */
.coa-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 10px 0;
    align-items: start;
    overflow: clip;
}
.coa-cols-1 { grid-template-columns: repeat(1, 1fr); }
.coa-cols-2 { grid-template-columns: repeat(2, 1fr); }
.coa-cols-3 { grid-template-columns: repeat(3, 1fr); }
.coa-cols-4 { grid-template-columns: repeat(4, 1fr); }

.coa-grid > * {
    min-width: 0;
}

/* ---- Base card ---- */
.coa-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--coa-card-border, #e8e8e8);
    border-radius: var(--coa-card-radius, 12px);
    overflow: hidden;
    transition: box-shadow 0.22s ease, transform 0.22s ease;
    text-decoration: none;
    color: inherit;
    isolation: isolate;
    min-width: 0;
}

.coa-card:hover {
    box-shadow: 0 10px 30px var(--coa-card-shadow, rgba(0, 0, 0, 0.10));
    transform: translateY(-3px);
}

/* ---- Card media area ---- */
.coa-card__media {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: #f4f4f4;
    flex-shrink: 0;
}

/* ---- Media link (wraps media for single-image + PDF cards) ---- */
.coa-card__media-link {
    display: block;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

/* ---- Single image ---- */
.coa-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #f7f8fa;
}

/* ================================================
   IMAGE LIGHTBOX
   ================================================ */

body.coa-image-lightbox-open {
    overflow: hidden;
}

.coa-image-lightbox[hidden] {
    display: none;
}

.coa-image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 72px;
}

.coa-image-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.86);
    cursor: zoom-out;
}

.coa-image-lightbox__figure {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: min(1100px, 92vw);
    max-height: 86vh;
    margin: 0;
}

.coa-image-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: calc(86vh - 38px);
    object-fit: contain;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.coa-image-lightbox__caption {
    max-width: 100%;
    margin-top: 12px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

.coa-image-lightbox__button {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: rgba(20, 20, 20, 0.78);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.coa-image-lightbox__button:hover,
.coa-image-lightbox__button:focus-visible {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(255, 255, 255, 0.72);
    color: #111111;
    outline: none;
    transform: scale(1.04);
}

.coa-image-lightbox__icon {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.coa-image-lightbox__close {
    top: 22px;
    right: 22px;
}

.coa-image-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
}

.coa-image-lightbox__nav:hover,
.coa-image-lightbox__nav:focus-visible {
    transform: translateY(-50%) scale(1.04);
}

.coa-image-lightbox__nav--prev {
    left: 22px;
}

.coa-image-lightbox__nav--next {
    right: 22px;
}

/* ================================================
   CAROUSEL
   ================================================ */

.coa-carousel {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(255,255,255,0.16), transparent 36%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.02), rgba(15, 23, 42, 0.14));
}

.coa-carousel__viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.coa-carousel__track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.coa-carousel__slide {
    position: relative;
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.coa-carousel__slide::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.04) 0%, rgba(15, 23, 42, 0) 35%, rgba(15, 23, 42, 0.12) 100%);
    pointer-events: none;
}

.coa-carousel__img-link {
    display: block;
    position: relative;
    inset: 0;
    text-decoration: none;
    width: 100%;
    height: 100%;
}

/* ---- Prev / Next buttons ---- */
.coa-carousel__btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #222;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(10px);
}

.coa-card--carousel:hover .coa-carousel__btn,
.coa-card--carousel:focus-within .coa-carousel__btn {
    opacity: 1;
}

.coa-carousel__btn--prev { left: 12px; }
.coa-carousel__btn--next { right: 12px; }

.coa-carousel__btn:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.05);
}

.coa-carousel__status {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.68);
    color: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(8px);
}

.coa-carousel__count {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ---- Dot indicators ---- */
.coa-carousel__dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 20;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.44);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(8px);
}

.coa-carousel__dot {
    width: 9px;
    height: 8px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease, width 0.2s ease;
}

.coa-carousel__dot.is-active {
    background: #ffffff;
    width: 22px;
    transform: none;
}

/* On mobile show buttons at all times (no hover on touch) */
@media (hover: none) {
    .coa-carousel__btn {
        opacity: 0.7;
    }
}

@media (max-width: 700px) {
    .coa-image-lightbox {
        padding: 58px 14px 74px;
    }

    .coa-image-lightbox__figure {
        max-width: 100%;
        max-height: 78vh;
    }

    .coa-image-lightbox__image {
        max-height: calc(78vh - 42px);
    }

    .coa-image-lightbox__button {
        width: 42px;
        height: 42px;
    }

    .coa-image-lightbox__close {
        top: 12px;
        right: 12px;
    }

    .coa-image-lightbox__nav {
        top: auto;
        bottom: 16px;
        transform: none;
    }

    .coa-image-lightbox__nav:hover,
    .coa-image-lightbox__nav:focus-visible {
        transform: scale(1.04);
    }

    .coa-image-lightbox__nav--prev {
        left: calc(50% - 56px);
    }

    .coa-image-lightbox__nav--next {
        right: calc(50% - 56px);
    }
}

/* ================================================
   PDF CARD
   ================================================ */

.coa-card__media--pdf {
    height: 600px;
    aspect-ratio: auto;
    overflow-y: auto;
    overflow-x: hidden;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.coa-pdf-object {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: 0;
    background: #ffffff;
}

.coa-pdf-fallback {
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    text-align: center;
    background: #f7f8fa;
    color: #475467;
}

.coa-pdf-fallback p {
    margin: 0;
}

.coa-pdf-fallback__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 16px;
    border-radius: var(--coa-btn-radius, 4px);
    background: var(--coa-btn-bg, #0071a1);
    color: var(--coa-btn-color, #ffffff) !important;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
}

.coa-pdf-fallback__link:hover {
    filter: brightness(0.94);
    text-decoration: none;
}

/* Transparent click-catcher above iframe — desktop only */
.coa-pdf-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: transparent;
    cursor: pointer;
}

/* PDF iframe — desktop only */
.coa-pdf-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
    display: block;
    background: #fff;
}

/* ---- Mobile PDF placeholder ---- */
/* Hidden on desktop; shown on mobile where iframes don't render PDFs */
.coa-pdf-mobile-placeholder {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 15;           /* above iframe(z:auto) and overlay(z:10) */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: linear-gradient(145deg, #f0f4f8 0%, #e8edf2 100%);
    pointer-events: none;  /* parent <a> handles the click */
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.coa-pdf-mobile-placeholder::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.22));
}

.coa-pdf-mobile-placeholder--image::before {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.34));
}

.coa-pdf-mobile-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 90%;
}

.coa-pdf-icon {
    width: 52px;
    height: 52px;
    color: #e53e3e;        /* red PDF colour */
    flex-shrink: 0;
}

.coa-pdf-mobile-name {
    font-size: 13px;
    font-weight: 700;
    color: #222;
    text-align: center;
    line-height: 1.3;
    max-width: 90%;
    /* clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.coa-pdf-mobile-placeholder--image .coa-pdf-mobile-name {
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(15, 23, 42, 0.55);
}

.coa-pdf-mobile-cta {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #e53e3e;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.02em;
    margin-top: 2px;
    box-shadow: 0 10px 20px rgba(229, 62, 62, 0.22);
}

/* ================================================
   CARD FOOTER — centred, theme-proof
   ================================================ */

.coa-card__footer {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.coa-card .coa-card__label {
    font-size: var(--coa-label-size, 14px);
    font-weight: 600;
    color: #111111 !important;
    margin: 0;
    line-height: 1.35;
    text-align: center;
}

.coa-card .coa-card__label-link {
    display: block;
    font-size: var(--coa-label-size, 14px);
    font-weight: 600;
    color: #111111 !important;
    margin: 0;
    line-height: 1.35;
    text-align: center;
    text-decoration: none;
    transition: color 0.15s ease;
}

.coa-card .coa-card__label-link:hover {
    color: var(--coa-btn-bg, #0071a1) !important;
    text-decoration: underline;
}

/* ---- Empty state ---- */
.coa-empty {
    padding: 20px 0;
    color: #888;
    font-style: italic;
}

/* ---- Product-specific shortcode ---- */
.coa-product-certificate {
    width: 100%;
}

.coa-product-certificate__results {
    width: 100%;
}

.coa-product-certificate__message {
    margin: 0;
}

.coa-product-certificate__message--loading {
    color: #555;
}

.coa-card__footer--stacked {
    flex-direction: column;
    gap: 8px;
}

.coa-card .coa-card__expiry {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    color: #555;
    text-align: center;
}

.coa-card .coa-card__expiry span {
    font-weight: 700;
}

.coa-card .coa-card__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 14px;
    border-radius: var(--coa-btn-radius, 4px);
    background: var(--coa-btn-bg, #0071a1);
    color: var(--coa-btn-color, #ffffff) !important;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.coa-card .coa-card__button:hover {
    filter: brightness(0.94);
    transform: translateY(-1px);
    text-decoration: none;
}

.coa-product-certificate--layout-list .coa-product-certificate__cards {
    grid-template-columns: 1fr;
}

.coa-product-certificate--layout-list .coa-card {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    align-items: stretch;
}

.coa-product-certificate--layout-list .coa-card__media,
.coa-product-certificate--layout-list .coa-card__media-link {
    min-width: 0;
}

.coa-product-certificate--layout-list .coa-card__media {
    height: 100%;
    min-height: 220px;
    aspect-ratio: auto;
}

.coa-product-certificate--layout-list .coa-card__media--pdf {
    height: 600px;
    min-height: 600px;
}

.coa-product-certificate--layout-list .coa-card__footer {
    border-top: 0;
    border-left: 1px solid #f0f0f0;
    justify-content: center;
}

/* ================================================
   Responsive
   ================================================ */

@media ( max-width: 1024px ) {
    .coa-grid,
    .coa-cols-3,
    .coa-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: hide iframe, show placeholder */
@media ( max-width: 768px ) {
    .coa-grid {
        gap: 16px;
    }

    .coa-card {
        transform: none !important;
    }

    .coa-carousel__btn {
        width: 36px;
        height: 36px;
        font-size: 22px;
        opacity: 0.88;
    }

    .coa-carousel__status {
        top: 10px;
        right: 10px;
    }

    .coa-carousel__dots {
        bottom: 10px;
        gap: 6px;
        padding: 7px 10px;
    }

    .coa-pdf-iframe,
    .coa-pdf-overlay {
        display: none;
    }

    .coa-pdf-mobile-placeholder {
        display: flex;
    }

    .coa-card__media.coa-card__media--pdf {
        height: 560px;
    }

    .coa-pdf-object,
    .coa-pdf-fallback {
        min-height: 560px;
    }
}

@media ( max-width: 600px ) {
    .coa-grid,
    .coa-cols-2,
    .coa-cols-3,
    .coa-cols-4 {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .coa-card__media {
        aspect-ratio: auto;
        height: clamp(280px, 88vw, 420px);
    }

    .coa-card__footer {
        padding: 12px 14px;
    }

    .coa-product-certificate--layout-list .coa-card {
        display: flex;
    }

    .coa-product-certificate--layout-list .coa-card__media {
        height: clamp(280px, 88vw, 420px);
    }

    .coa-product-certificate--layout-list .coa-card__media.coa-card__media--pdf,
    .coa-card__media.coa-card__media--pdf {
        height: 520px;
    }

    .coa-pdf-object,
    .coa-pdf-fallback {
        min-height: 520px;
    }

    .coa-product-certificate--layout-list .coa-card__footer {
        border-top: 1px solid #f0f0f0;
        border-left: 0;
    }

    .coa-carousel__btn--prev {
        left: 10px;
    }

    .coa-carousel__btn--next {
        right: 10px;
    }
}

/* ================================================
   Certificates Tab — per-type badge + desktop columns
   Scope: only inside the WooCommerce product Certificates tab.
   Archive (.coa-search-wrap) and single-product shortcode output
   are NOT affected.
   ================================================ */

/* Desktop / tablet-landscape: force 3 per row inside the tab.
   Overrides the global @media (max-width: 1024px) → 2-col rule
   for widths above the mobile breakpoint (>=769px). */
@media ( min-width: 769px ) {
    .coa-tab-section .coa-grid,
    .coa-tab-section .coa-cols-1,
    .coa-tab-section .coa-cols-2,
    .coa-tab-section .coa-cols-3,
    .coa-tab-section .coa-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Small badge overlay on each card image (top-left) — replaces the old H3 section title. */
.coa-tab-section .coa-card {
    position: relative;
}

.coa-tab-section .coa-card::before {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--coa-btn-bg, #0071a1);
    color: var(--coa-btn-color, #ffffff);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.coa-tab-section--purity .coa-card::before {
    content: "Purity Test";
}

.coa-tab-section--metal .coa-card::before {
    content: "Metal Test";
}

.coa-tab-section--endotoxins .coa-card::before {
    content: "Endotoxins Test";
}

/* Legacy (untyped) tab section — no badge. */
.coa-tab-section:not([class*="coa-tab-section--"]) .coa-card::before {
    content: none;
}

/* Small spacing between successive tab sections when they stack vertically. */
.coa-tab-section + .coa-tab-section {
    margin-top: 24px;
}

/* Desktop: when the tab has 2+ sections, arrange them side-by-side in a flex row.
   Each section becomes a slim column, so its internal 3-col grid collapses to 1.
   Mobile / below 769px: the row wrapper is a plain block, sections stack normally. */
@media ( min-width: 769px ) {
    .coa-tab-sections-row {
        display: flex;
        gap: 20px;
        align-items: flex-start;
    }

    .coa-tab-sections-row > .coa-tab-section {
        flex: 1 1 0;
        min-width: 0;
    }

    .coa-tab-sections-row > .coa-tab-section + .coa-tab-section {
        margin-top: 0;
    }

    .coa-tab-sections-row > .coa-tab-section .coa-grid {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   Table layout — [coa_certificates layout="table"]
   ═══════════════════════════════════════════════════════════════════ */

.coa-table-container {
    color: #1f2937;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

.coa-table-header {
    padding: 4px 4px 14px;
    color: #111827;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.1px;
}

.coa-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--coa-table-border, #e5e7eb);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.coa-table {
    width: 100%;
    border: 0 !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    background: transparent;
    font-size: 15px;
}

/* Neutralize any vertical dividers a theme might inject. Only horizontal
   row separators live on the tbody rows. */
.coa-table th,
.coa-table td {
    border: 0 !important;
    background: transparent;
}

.coa-table__th,
.coa-table__td {
    padding: 18px 20px;
    text-align: left;
    vertical-align: middle;
    line-height: 1.45;
}

.coa-table__th {
    color: var(--coa-table-header-text, #4b3f2a);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: 0.1px;
    padding-top: 16px;
    padding-bottom: 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--coa-table-border, #e5e7eb) !important;
    background: var(--coa-table-header-bg, #fbfaf8) !important;
}

.coa-table__th--actions { text-align: center; }

/* Only the row bottom border — no verticals anywhere. */
.coa-table__row {
    border-bottom: 1px solid var(--coa-table-border, #eef0f2);
}

.coa-table tbody tr:last-child { border-bottom: 0; }

.coa-table__row:hover .coa-table__td {
    background: var(--coa-table-row-hover, #fafbfc);
}

/* ── Product cell ─────────────────────────────── */
.coa-table__td--product { min-width: 240px; }

.coa-table__product {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.coa-table__thumb {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    background: #edf2f7;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coa-table__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.coa-table__thumb--empty {
    background-image: linear-gradient(135deg, #dae4ee 0%, #eef3f8 100%);
}

.coa-table__product-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
}

/* Name + type-badge sit on the same line */
.coa-table__product-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.coa-table__product-name {
    font-weight: 700;
    color: #111827;
    font-size: 16px;
    line-height: 1.35;
    letter-spacing: -0.1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Test-type badge — only rendered for Purity / Metal rows. Legacy has no badge. */
.coa-table__type-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.2;
    white-space: nowrap;
    border: 1px solid transparent;
}

.coa-table__type-badge--purity {
    background: var(--coa-table-badge-purity-bg, #dcfce7);
    color: var(--coa-table-badge-purity-text, #15803d);
    /* Border matches bg so admin only has to think about two colors per badge. */
    border-color: var(--coa-table-badge-purity-bg, #bbf7d0);
}

.coa-table__type-badge--metal {
    background: var(--coa-table-badge-metal-bg, #fef3c7);
    color: var(--coa-table-badge-metal-text, #92400e);
    border-color: var(--coa-table-badge-metal-bg, #fde68a);
}

.coa-table__type-badge--endotoxins {
    background: var(--coa-table-badge-endotoxins-bg, #ede9fe);
    color: var(--coa-table-badge-endotoxins-text, #5b21b6);
    border-color: var(--coa-table-badge-endotoxins-bg, #ddd6fe);
}

.coa-table__product-cat {
    font-weight: 400;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Data cells — batch / date / lab / purity ─────────────────── */
.coa-table__td--batch,
.coa-table__td--purity,
.coa-table__td--date,
.coa-table__td--lab {
    white-space: nowrap;
    font-size: 15px;
}

.coa-table__td--batch,
.coa-table__td--date,
.coa-table__td--lab {
    color: var(--coa-table-data-text, #111827);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.coa-table__td--purity {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.coa-table__purity        { color: var(--coa-table-purity, #22c55e); }
.coa-table__purity--empty { color: #9ca3af; font-weight: 400; }

/* ── Actions ─────────────────────────────── */
.coa-table__td--actions {
    text-align: center;
    white-space: nowrap;
    min-width: 240px;
    vertical-align: middle;
}

.coa-table__td--actions > * + * { margin-left: 14px; }

.coa-table__action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: transform 0.15s ease, color 0.15s ease, background-color 0.15s ease,
                border-color 0.15s ease, box-shadow 0.2s ease;
}

/* View Product — subtle chip. `!important` on color beats theme rules that
   force link color across the content area (e.g. `.entry-content a { color: … }`). */
.coa-table__action--view {
    color: var(--coa-table-view-text, #1d4ed8) !important;
    background: var(--coa-table-view-bg, #eff6ff);
    border-color: var(--coa-table-view-bg, #dbeafe);
}

.coa-table__action--view:hover {
    color: var(--coa-table-view-hover-text, #ffffff) !important;
    background: var(--coa-table-view-hover-bg, #2563eb);
    border-color: var(--coa-table-view-hover-bg, #2563eb);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Force the label + icon spans to follow the anchor's colour — some themes
   target inline elements directly and reset colour to black. */
.coa-table__action--view .coa-table__action-label,
.coa-table__action--view .coa-table__action-icon,
.coa-table__action--coa .coa-table__action-label,
.coa-table__action--coa .coa-table__action-icon {
    color: inherit !important;
}

.coa-table__action--view .coa-table__action-icon { font-size: 13px; }

/* COA — solid primary CTA (single flat color, admin-configurable) */
.coa-table__action--coa {
    color: var(--coa-table-coa-text, #ffffff) !important;
    background: var(--coa-table-coa-bg, #2563eb);
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.coa-table__action--coa:hover {
    color: var(--coa-table-coa-text, #ffffff) !important;
    background: var(--coa-table-coa-hover-bg, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.coa-table__action--coa:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

.coa-table__action--coa .coa-table__action-icon { font-size: 13px; }

/* Metadata-only rows — flat muted pill, no gradient / shadow */
.coa-table__action--coa-empty,
.coa-table__action--coa-empty:hover {
    cursor: not-allowed;
    color: #9ca3af;
    background: #f4f5f7;
    border-color: #e5e7eb;
    box-shadow: none;
    transform: none;
}

/* ── Search-wrap in table mode — no grid padding ─────── */
.coa-search-wrap--table .coa-search-results { padding: 0; }

/* ── Compact breakpoint: below 1100px, shrink padding a bit to keep things on one row */
@media (max-width: 1100px) {
    .coa-table__th,
    .coa-table__td { padding: 14px 16px; }
    .coa-table__th { font-size: 15px; }
    .coa-table__td--batch,
    .coa-table__td--purity,
    .coa-table__td--date,
    .coa-table__td--lab { font-size: 14px; }
    .coa-table__td--product,
    .coa-table__td--actions { min-width: 210px; }
    .coa-table__action { font-size: 14px; }
    .coa-table__action--coa { padding: 6px 14px; }
}

/* ── Mobile stacking (below 780px) ───────────────────────────────
   Each row becomes a card:
   • Product row: thumbnail + name + category
   • Data rows: label + "→" on the left, value on the right, subtle divider
   • Actions: stacked centered — View Product = plain link, COA = outlined pill
   Backgrounds/borders keep using the same CSS vars as desktop so admin
   colors flow through here too.
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 780px) {
    .coa-table-wrap {
        border: 0;
        background: transparent;
        box-shadow: none;
        overflow-x: visible;
    }

    .coa-table,
    .coa-table thead,
    .coa-table tbody,
    .coa-table tr,
    .coa-table th,
    .coa-table td {
        display: block;
        width: auto;
    }

    .coa-table thead {
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        height: 1px;
        overflow: hidden;
        position: absolute;
        white-space: nowrap;
        width: 1px;
    }

    .coa-table__row {
        border: 1px solid var(--coa-table-border, #e5e7eb) !important;
        border-radius: 14px;
        margin-bottom: 18px;
        background: #fff;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    }

    .coa-table__row:hover .coa-table__td { background: transparent; }

    .coa-table__td {
        border-bottom: 1px solid #eef0f2;
        padding: 0;
        min-width: 0;
        white-space: normal;
        text-align: left;
    }

    .coa-table__td:last-child { border-bottom: 0; }

    /* Product row — thumbnail + name + category, no label prefix */
    .coa-table__td--product {
        padding: 18px 20px;
    }

    .coa-table__product { gap: 14px; }

    .coa-table__product-name { white-space: normal; }

    /* Data rows — label←→value flex, arrow after label */
    .coa-table__td[data-label] {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        padding: 14px 20px;
        font-size: 15px;
    }

    .coa-table__td[data-label]::before {
        content: attr(data-label) " \2192";  /* "→" */
        color: #94a3b8;
        font-weight: 500;
        font-size: 15px;
        letter-spacing: 0.1px;
        flex-shrink: 0;
        margin: 0;
        text-transform: none;
    }

    /* Values on the right — dark, bold */
    .coa-table__td--batch,
    .coa-table__td--date,
    .coa-table__td--lab {
        color: var(--coa-table-data-text, #111827);
        font-weight: 700;
        text-align: right;
    }

    .coa-table__td--purity {
        font-weight: 700;
        text-align: right;
    }

    /* Actions — centered vertical stack, 15px between View Product and COA.
       `!important` on display beats the higher-specificity base rule
       `.coa-table td { display: block }` above — without it, the actions
       cell stayed block and `gap` had no effect. */
    .coa-table__td--actions {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        gap: 15px;
        padding: 20px;
        text-align: center;
        min-width: 0;
    }

    .coa-table__td--actions > * + * { margin-left: 0; }

    /* Mobile actions — inherit the desktop colours the admin already
       configured (bg / text / border on both View Product and COA).
       The only mobile-specific adjustment is that the COA pill goes
       full-width up to a 320px cap so it reads as the primary CTA
       when the row stacks. */
    .coa-table__action--view {
        padding: 10px 18px;
    }

    .coa-table__action--coa {
        width: 100%;
        max-width: 320px;
        justify-content: center;
        padding: 12px 24px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   Single-product cards — [product_coa_certificate layout="cards"]
   Reuses the table's CSS vars (--coa-table-*) so one admin control set
   drives both surfaces.
   ═══════════════════════════════════════════════════════════════════ */

.coa-cards {
    /* Flexbox, not grid — grid's `1fr` was stretching cards to fill leftover
       space. Flex keeps each card at its fixed width and simply wraps to a new
       line when there's no more room. */
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: flex-start;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.coa-card-box {
    position: relative;
    background: #fff;
    border: 1px solid var(--coa-table-border, #e5e7eb);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Fixed width so leftover space stays empty instead of stretching cards.
       max-width caps to the container on narrow screens. */
    flex: 0 0 auto;
    width: 320px;
    max-width: 100%;
}

/* On narrow (mobile) screens, let cards span full width. */
@media (max-width: 480px) {
    .coa-card-box { width: 100%; }
}

.coa-card-box__latest {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--coa-card-latest-bg, #3b82f6);
    color: var(--coa-card-latest-text, #ffffff);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    letter-spacing: 0.2px;
    z-index: 1;
}

.coa-card-box__purity-wrap {
    text-align: center;
    padding-top: 20px; /* clears the Latest badge */
}

.coa-card-box__purity {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--coa-table-purity, #22c55e);
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
}

.coa-card-box__purity--empty {
    /* Keeps the green tint even when N/A%, matching the reference. */
    color: var(--coa-table-purity, #22c55e);
}

.coa-card-box__purity-label {
    font-size: 14px;
    color: #6b7280;
    margin-top: 4px;
    font-weight: 500;
}

.coa-card-box__meta {
    background: #f8fafc;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.coa-card-box__meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    line-height: 1.3;
    min-width: 0;
}

.coa-card-box__meta-row dt {
    color: #6b7280;
    font-weight: 500;
    margin: 0;
    flex-shrink: 0;
    letter-spacing: 0.1px;
}

.coa-card-box__meta-row dd {
    color: var(--coa-table-data-text, #111827);
    font-weight: 600;
    margin: 0;
    text-align: right;
    word-break: break-word;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

.coa-card-box__actual {
    color: #9ca3af;
    font-weight: 500;
}

.coa-card-box__actual--set {
    color: var(--coa-table-purity, #22c55e);
    font-weight: 700;
}

.coa-card-box__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--coa-table-coa-bg, #2563eb);
    color: var(--coa-table-coa-text, #ffffff) !important;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.1px;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
    align-self: stretch;
    border: 0;
}

.coa-card-box__btn:hover {
    background: var(--coa-table-coa-hover-bg, #1d4ed8);
    color: var(--coa-table-coa-text, #ffffff) !important;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.coa-card-box__btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

.coa-card-box__btn--empty,
.coa-card-box__btn--empty:hover {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ═══════════════════════════════════════════════════════════════════
   Defensive visibility guards — `html body` prefix bumps specificity so
   theme rules using `!important` on lower-specificity selectors lose.
   Themes commonly hide table content via `.woocommerce table td {
   display: none }` inside responsive media queries; those get beaten
   here. Split into desktop-safe defaults + mobile stacking so we don't
   force `display: block` on the table itself on desktop (which would
   destroy the column layout).
   ═══════════════════════════════════════════════════════════════════ */
html body .coa-table-container,
html body .coa-table-wrap,
html body .coa-table,
html body .coa-table tbody,
html body .coa-table__row,
html body .coa-table__td,
html body .coa-table__action,
html body .coa-table__action-label,
html body .coa-table__action-icon,
html body .coa-cards,
html body .coa-card-box,
html body .coa-card-box__btn {
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    height: auto !important;
}

/* Desktop-safe display defaults (all viewports).
   `.coa-table` forced to `display: table` here so theme rules like
   `.woocommerce table { display: none }` — which were breaking the
   TABLET view (800–1024px, outside the ≤780px mobile media query) —
   get overridden. Mobile flips this to `display: block` below. */
html body .coa-table-container { display: block !important; }
html body .coa-table-wrap      { display: block !important; }
html body .coa-table           { display: table !important; }
html body .coa-table tbody     { display: table-row-group !important; }
html body .coa-table__row      { display: table-row !important; }
html body .coa-table__td       { display: table-cell !important; }
html body .coa-cards           { display: flex !important; }
html body .coa-card-box        { display: flex !important; }

/* Ensure the two action-cell children (View Product / COA) can't be
   hidden by theme rules that target `a` or `span` inside table cells. */
html body .coa-table__action        { display: inline-flex !important; }
html body .coa-table__action-label,
html body .coa-table__action-icon   { display: inline !important; }
html body .coa-card-box__btn        { display: inline-flex !important; }

/* Mobile stacking: force table + tbody + rows into blocks so they lay
   out as cards. Data cells stay as flex (label←→value), actions cell as
   a vertical flex stack, product cell as a block containing its own
   flex row. */
@media (max-width: 780px) {
    html body .coa-table,
    html body .coa-table tbody,
    html body .coa-table__row,
    html body .coa-table__td--product { display: block !important; }
    html body .coa-table__td[data-label] { display: flex !important; }
    html body .coa-table__td--actions   { display: flex !important; }
    /* On mobile the COA action pill goes full-width up to 320px */
    html body .coa-table__action--coa   { display: inline-flex !important; }
}
