/**
 * PingGalaxy — Raquette préconfigurée (preset product page)
 * Reuses the STANDARD product interface (.pg-product-columns /
 * .pg-product-info / .pg-product-meta-line / .pg-product-price / sticky footer).
 * This file only styles the preset-specific bits: left composition column,
 * level badge, "offert" line, add button, stockout, components section, modal.
 * Mobile-first. Uses var(--pg-*) tokens only.
 *
 * @package TT_Expert_Child
 */

/* ============================================================
   Left column — clickable composition (replaces image gallery)
   ============================================================ */

.pg-preset-composition {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    align-content: start;
}

/* Component card — reset the button, ciblé (pas de all:unset) */
.pg-preset-comp {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 12px 10px;
    background: none;
    border: 1px solid var(--pg-border-light);
    border-radius: var(--pg-radius-lg);
    cursor: pointer;
    text-align: center;
    font: inherit;
    color: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.pg-preset-comp:hover {
    border-color: var(--pg-galaxy);
    box-shadow: var(--pg-shadow-sm);
}

.pg-preset-comp:focus-visible {
    outline: 2px solid var(--pg-galaxy);
    outline-offset: 2px;
}

.pg-preset-comp--empty {
    cursor: default;
}

.pg-preset-comp--empty:hover {
    border-color: var(--pg-border-light);
    box-shadow: none;
}

.pg-preset-comp-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--pg-radius-md);
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-preset-comp-img img,
.pg-preset-comp-img-el {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Text body wrapper — keeps role/name/variant/price together in the flex row */
.pg-preset-comp-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.pg-preset-comp-role {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pg-grey-light);
}

.pg-preset-comp-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--pg-dark);
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
}

.pg-preset-comp-variant {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.pg-preset-comp-swatch {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--swatch, var(--pg-border-medium));
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.pg-preset-comp-tag {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--pg-grey-medium);
    background: var(--pg-bg-light);
    border: 1px solid var(--pg-border-light);
    border-radius: var(--pg-radius-pill);
    padding: 1px 7px;
    white-space: nowrap;
    line-height: 1.4;
}

.pg-preset-comp-price {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--pg-grey);
}

.pg-preset-comp-price .woocommerce-Price-amount {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

/* 481–640px: 2-col grid (3-col is too tight below tablet) */
@media (max-width: 640px) {
    .pg-preset-composition {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .pg-preset-comp {
        padding: 10px 8px;
    }
}

/* ≤480px: single column, horizontal card layout (image + text side-by-side) */
@media (max-width: 480px) {
    .pg-preset-composition {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .pg-preset-comp {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        text-align: left;
        padding: 10px 12px;
        box-sizing: border-box;
    }

    .pg-preset-comp-img {
        width: 64px;
        flex-shrink: 0;
        /* keep aspect-ratio:1/1 from base rule — 64×64px */
    }

    .pg-preset-comp-body {
        align-items: flex-start;
    }

    .pg-preset-comp-variant {
        justify-content: flex-start;
    }
}

/* ============================================================
   Right column — mobile overrides for shared product-info elements
   (title, meta-line, price, badges) scoped to preset page
   ============================================================ */

@media (max-width: 480px) {
    /* Title: 30px → 22px at 320px feels right for long racket names */
    .pg-preset-page .pg-product-title {
        font-size: 22px;
    }

    /* Price: 32px → 24px to avoid overflow and stay proportional */
    .pg-preset-page .pg-product-price .woocommerce-Price-amount {
        font-size: 24px;
    }

    /* Meta line: hide separator bars when items wrap — they look orphaned */
    .pg-preset-page .pg-product-meta-separator {
        display: none;
    }

    /* Allow play-style badge to wrap on very small screens */
    .pg-preset-page .pg-product-style-badge {
        white-space: normal;
        word-break: break-word;
    }

    /* Allow preset level badge to wrap similarly */
    .pg-preset-page .pg-preset-badge {
        white-space: normal;
        word-break: break-word;
    }
}

/* ============================================================
   Right column — preset-specific bits (badge / offert / actions)
   ============================================================ */

.pg-preset-badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 3px 10px;
    border-radius: var(--pg-radius-pill);
    background: var(--pg-galaxy-light-bg);
    color: var(--pg-galaxy);
    border: 1px solid var(--pg-galaxy-border);
}

.pg-preset-badge--confirme {
    background: var(--pg-level-confirme-bg);
    color: var(--pg-level-confirme-text);
    border-color: var(--pg-level-confirme-border);
}

.pg-preset-offert {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--pg-success);
    margin: 0 0 20px;
}

.pg-preset-offert svg {
    flex-shrink: 0;
    stroke: var(--pg-success);
}

/* Estimation de livraison
   Répliqué depuis product-info.css : la fiche preset ne charge que preset.css,
   product-info.css et preset.css sont volontairement disjoints (anti-conflit). */
.pg-delivery-estimate {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: -8px;
    margin-bottom: 24px;
    padding: 10px 16px;
    background: var(--pg-bg-light);
    border: 1px solid var(--pg-border-light);
    border-radius: 2px;
    font-size: 13px;
    font-weight: 500;
    color: var(--pg-grey-medium);
}

.pg-delivery-icon {
    flex-shrink: 0;
    color: var(--pg-grey-medium);
}

.pg-delivery-estimate-text {
    line-height: 1.4;
}

/* ============================================================
   Add-to-cart actions
   ============================================================ */

.pg-preset-actions {
    margin-bottom: 24px;
}

.pg-preset-add {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--pg-galaxy);
    color: var(--pg-white);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--pg-radius-md);
    cursor: pointer;
    transition: background 0.18s ease, opacity 0.18s ease;
    min-height: 52px;
    touch-action: manipulation;
}

.pg-preset-add:hover:not(:disabled) {
    background: var(--pg-galaxy-hover);
}

.pg-preset-add:focus-visible {
    outline: 2px solid var(--pg-galaxy);
    outline-offset: 2px;
}

.pg-preset-add:disabled,
.pg-preset-add[aria-disabled="true"] {
    background: var(--pg-border-medium);
    color: var(--pg-grey-medium);
    cursor: not-allowed;
    opacity: 0.7;
}

.pg-preset-add .pg-btn-cart-icon {
    flex-shrink: 0;
}

/* Loading state */
.pg-preset-add--loading .pg-preset-add-text,
.pg-preset-add--loading .pg-btn-cart-icon {
    opacity: 0;
}

.pg-preset-add-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--pg-white-alpha-30);
    border-top-color: var(--pg-white);
    border-radius: 50%;
}

.pg-preset-add--loading .pg-preset-add-spinner {
    display: inline-block;
    position: absolute;
    animation: pg-preset-spin 0.7s linear infinite;
}

@keyframes pg-preset-spin {
    to { transform: rotate(360deg); }
}

.pg-preset-stockout {
    margin-top: 10px;
    font-size: 0.875rem;
    color: var(--pg-stock-out-text);
    background: var(--pg-stock-out-bg);
    border-radius: var(--pg-radius-md);
    padding: 8px 12px;
}

/* ============================================================
   Components section ("Ce que nos experts ont mis dedans")
   ============================================================ */

.pg-preset-components-section {
    background: var(--pg-bg-light);
    border-top: 1px solid var(--pg-border-light);
    padding: 40px 0;
    margin-top: 32px;
}

.pg-preset-components-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
}

.pg-preset-components-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--pg-dark);
    margin: 0 0 28px;
}

.pg-preset-components {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pg-preset-component {
    display: flex;
    gap: 16px;
    background: var(--pg-white);
    border: 1px solid var(--pg-border-light);
    border-radius: var(--pg-radius-lg);
    padding: 16px;
    box-shadow: var(--pg-shadow-xs);
}

.pg-preset-component-image {
    flex-shrink: 0;
    width: 80px;
}

.pg-preset-component-image a {
    display: block;
    border-radius: var(--pg-radius-md);
    overflow: hidden;
    border: 1px solid var(--pg-border);
}

.pg-preset-component-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.pg-preset-component-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pg-preset-component-role {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pg-grey-medium);
}

.pg-preset-component-brand {
    font-size: 0.78rem;
    color: var(--pg-grey);
}

.pg-preset-component-name {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 4px 0 8px;
}

.pg-preset-component-name a {
    color: var(--pg-dark);
    text-decoration: none;
    word-break: break-word;
    overflow-wrap: break-word;
}

.pg-preset-component-name a:hover {
    color: var(--pg-galaxy);
    text-decoration: underline;
}

.pg-preset-component-modules {
    margin-top: 4px;
}

/* Desktop grid: components side-by-side */
@media (min-width: 768px) {
    .pg-preset-components {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .pg-preset-component {
        flex-direction: column;
    }

    .pg-preset-component-image {
        width: 100%;
    }

    .pg-preset-component-image a {
        aspect-ratio: 1 / 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .pg-preset-component-img {
        height: 100%;
        object-fit: contain;
    }
}

/* Component variant line (chosen color / épaisseur / dureté + price) */
.pg-preset-component-variant {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 4px 0 6px;
}

.pg-preset-component-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--swatch, var(--pg-border-medium));
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.pg-preset-component-variant-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--pg-grey-medium);
    background: var(--pg-bg-light);
    border: 1px solid var(--pg-border-light);
    border-radius: var(--pg-radius-pill);
    padding: 2px 8px;
    white-space: nowrap;
    line-height: 1.4;
}

.pg-preset-component-price {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--pg-price);
    margin-left: auto;
}

.pg-preset-component-price .woocommerce-Price-amount {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

@media (max-width: 480px) {
    .pg-preset-components-section {
        padding: 28px 0;
        margin-top: 20px;
    }

    .pg-preset-components-title {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    .pg-preset-component {
        padding: 12px;
        gap: 12px;
    }

    .pg-preset-component-image {
        width: 64px;
    }

    /* Component name: ensure long strings wrap */
    .pg-preset-component-name {
        font-size: 0.875rem;
    }

    /* Variant line: break price to its own row to avoid collision with chips */
    .pg-preset-component-variant {
        row-gap: 4px;
    }

    .pg-preset-component-price {
        margin-left: 0;
        flex-basis: 100%;
        font-size: 0.875rem;
    }
}

/* ============================================================
   Component detail modal (embed-mode iframe)
   ============================================================ */

.pg-preset-modal[hidden] {
    display: none;
}

.pg-preset-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.pg-preset-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.pg-preset-modal__dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    /* Au moins 1024px de large sur desktop pour que la fiche produit dans
       l'iframe affiche son VRAI rendu 2 colonnes (le breakpoint desktop des
       fiches produit est à 1024px) et non sa version 1 colonne. */
    max-width: min(1320px, 95vw);
    height: 90vh;
    background: var(--pg-white);
    border-radius: var(--pg-radius-lg);
    overflow: hidden;
    box-shadow: var(--pg-shadow-lg);
}

.pg-preset-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: var(--pg-bg-light);
    border-bottom: 1px solid var(--pg-border);
    flex-shrink: 0;
}

.pg-preset-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--pg-dark);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-preset-modal__close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--pg-dark);
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--pg-white);
    cursor: pointer;
    box-shadow: var(--pg-shadow-sm);
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.pg-preset-modal__close:hover {
    background: var(--pg-galaxy);
    color: var(--pg-white);
    transform: scale(1.05);
}

.pg-preset-modal__close:focus-visible {
    outline: 2px solid var(--pg-galaxy);
    outline-offset: 2px;
}

.pg-preset-modal__body {
    position: relative;
    flex: 1;
    min-height: 0;
}

.pg-preset-modal__iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.pg-preset-modal__loader {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 3px solid var(--pg-border-light);
    border-top-color: var(--pg-galaxy);
    border-radius: 50%;
    animation: pg-preset-spin 0.7s linear infinite;
    z-index: 1;
}

body.pg-modal-open {
    overflow: hidden;
}

/* Fullscreen modal on mobile */
@media (max-width: 640px) {
    .pg-preset-modal {
        padding: 0;
    }

    .pg-preset-modal__dialog {
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }

    /* Header lisible comme barre de popup + cible tactile généreuse */
    .pg-preset-modal__header {
        padding: 12px 14px;
        background: var(--pg-bg-light);
        border-bottom: 2px solid var(--pg-border);
        box-shadow: var(--pg-shadow-sm);
    }

    .pg-preset-modal__close {
        width: 44px;
        height: 44px;
        font-size: 1.75rem;
    }
}
