/* Styles du composant ArticleCard (mosaïque picking).
   Extraits du composant : un bloc <style> dans le markup est émis pour CHAQUE carte
   (16 Ko × N cartes dans le rendu SignalR). Ici il est chargé une seule fois. */
.compact-card-wrapper {
        width: 140px;
        outline: none;
        cursor: pointer;
        position: relative;
        transition: transform 0.2s ease;
    }

    .compact-card-wrapper:hover {
        transform: translateY(-2px);
    }

    .compact-card-wrapper:hover .compact-card {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .compact-card-wrapper:focus,
    .compact-card-wrapper.focused {
        transform: scale(1.08);
        z-index: 10;
    }

    .compact-card-wrapper:focus .compact-card,
    .compact-card-wrapper.focused .compact-card {
        box-shadow: 0 0 0 3px var(--mud-palette-primary), 0 8px 24px rgba(0, 0, 0, 0.6);
        border-radius: 0 8px 0 0;
    }

    .compact-card-wrapper:focus .expansion-tab,
    .compact-card-wrapper.focused .expansion-tab {
        box-shadow: -3px -3px 0 0 var(--mud-palette-primary), 3px -3px 0 0 var(--mud-palette-primary);
    }

    .expansion-tab {
        position: absolute;
        top: 0;
        left: 0;
        width: 28px;
        height: 22px;
        background: #374151;
        border-radius: 6px 6px 0 0;
        padding: 3px 4px;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .expansion-tab .expansion-icon svg,
    .expansion-tab .expansion-icon svg * {
        fill: #e5e7eb !important;
    }

    /* Badge numéro de commande - positionné en haut à droite */
    .order-number-tab {
        position: absolute;
        top: 0;
        right: 0;
        width: 56px;
        height: 44px;
        background: var(--opaps-gold, #b9900b);
        border-radius: 6px 6px 0 0;
        padding: 4px 6px;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-family: Arial, sans-serif;
        font-size: 27.5px;
        font-weight: 700;
        line-height: 1;
    }

    .compact-card-wrapper:focus .order-number-tab,
    .compact-card-wrapper.focused .order-number-tab {
        box-shadow: -3px -3px 0 0 var(--mud-palette-primary), 3px -3px 0 0 var(--mud-palette-primary);
    }

    .order-number-tab.ct-order-tab {
        background: linear-gradient(135deg, #2563eb, #1e40af);
        flex-direction: column;
        font-size: 22px;
    }
    .ct-order-prefix { font-size: 10px; letter-spacing: 1px; line-height: 1; }

    /* Badge quantité - positionné à droite du expansion-tab */
    .quantity-badge {
        position: absolute;
        top: 0;
        left: 28px;
        height: 22px;
        min-width: 18px;
        padding: 0 6px;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        font-weight: 700;
        color: var(--opaps-gold, #b9900b);
        z-index: 1;
        transition: color 0.15s ease-out;
    }

    /* Animation "pop" continue quand sélectionné */
    .quantity-badge.selected {
        color: #ff4444;
        animation: quantity-pop 0.9s ease-in-out infinite;
    }

    @keyframes quantity-pop {
        0%, 100% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.3);
        }
    }

    .promo-label {
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        height: 22px;
        line-height: 22px;
        font-size: 0.65rem;
        font-weight: 600;
        color: #ff9800;
        z-index: 1;
        transition: color 0.15s ease-out;
    }

    .promo-label.selected {
        color: #ff4444;
        animation: quantity-pop 0.9s ease-in-out infinite;
    }

    .inbox-label {
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        height: 22px;
        line-height: 22px;
        font-size: 0.65rem;
        font-weight: 600;
        color: #3b82f6;
        z-index: 1;
        transition: color 0.15s ease-out;
    }

    .inbox-label.selected {
        color: #2563eb;
        animation: quantity-pop 0.9s ease-in-out infinite;
    }

    .compact-card {
        width: 100%;
        margin-top: 22px;
        border-radius: 0 8px 8px 8px;
        background: #374151;
        overflow: hidden;
        transition: box-shadow 0.2s ease;
        position: relative;
    }

    .compact-card.has-order-tab {
        border-radius: 0 0 8px 8px;
    }

    .compact-card-wrapper:focus .compact-card.has-order-tab,
    .compact-card-wrapper.focused .compact-card.has-order-tab {
        border-radius: 0;
    }

    .compact-card .card-image {
        width: 100%;
        height: auto;
        aspect-ratio: 5 / 7;
        object-fit: contain;
        background: #374151;
        display: block;
    }

    /* Zone image — accueille l'image (+ éventuel foil wrap) et l'overlay count */
    .ac-img-zone {
        position: relative;
        width: 100%;
        aspect-ratio: 5 / 7;
        container-type: size;
    }

    /* Bouton « ajouter un range » (module Ranges), visible au survol de la carte. */
    .ac-range-btn {
        position: absolute; top: 4px; right: 4px; z-index: 6;
        width: 22px; height: 22px; border: none; border-radius: 4px;
        background: rgba(0,0,0,.65); color: #fff; cursor: pointer;
        display: none; align-items: center; justify-content: center; padding: 0;
    }
    .compact-card-wrapper:hover .ac-range-btn { display: flex; }
    .ac-range-btn:hover { background: #f59e0b; color: #111; }

    /* Bouton « stock à vérifier », à gauche du bouton range */
    .ac-verify-btn {
        position: absolute; top: 4px; right: 30px; z-index: 6;
        width: 22px; height: 22px; border: none; border-radius: 4px;
        background: rgba(0,0,0,.65); color: #fff; cursor: pointer;
        display: none; align-items: center; justify-content: center; padding: 0;
    }
    .compact-card-wrapper:hover .ac-verify-btn { display: flex; }
    .ac-verify-btn:hover { background: #3b82f6; color: #fff; }

    /* Badges sur l'image (langue, état, foil…) : masqués par défaut, affichés par le mode « tapis » du picking. */
    .ac-badges-overlay { display: none; }
    /* Nom du set sous le nom de la carte : masqué par défaut, affiché par le mode « tapis » (carte courante). */
    .card-set, .card-order { display: none; }

    /* Count overlay — visible uniquement quand la carte a le focus.
       Rempli or de l'identité graphique avec contour noir épais. */
    .ac-count-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: 'Poppins', sans-serif;
        font-weight: 800;
        font-size: 40cqh;
        line-height: 1;
        color: var(--opaps-gold, #b9900b);
        -webkit-text-stroke: 3px #000;
        paint-order: stroke fill;
        text-shadow:
            0 4px 12px rgba(0,0,0,0.65),
            0 0 18px rgba(0,0,0,0.5);
        pointer-events: none;
        opacity: 0;
        transform: scale(0.5);
        transition: none;
        z-index: 20;
    }

    .ac-count-overlay.visible {
        opacity: 1;
        animation: ac-count-pulse 1.1s ease-in-out infinite;
    }

    @keyframes ac-count-pulse {
        0%, 100% { transform: scale(1);    }
        50%      { transform: scale(1.18); }
    }

    /* Extra overlay — au-dessus du count, 3x plus petit */
    .ac-extra-overlay {
        position: absolute;
        left: 0;
        right: 0;
        top: 18%;
        text-align: center;
        font-family: 'Poppins', sans-serif;
        font-weight: 800;
        font-size: 13.3cqh;
        line-height: 1;
        letter-spacing: 0.5px;
        color: var(--opaps-gold, #b9900b);
        -webkit-text-stroke: 2px #000;
        paint-order: stroke fill;
        text-shadow:
            0 3px 8px rgba(0,0,0,0.65),
            0 0 14px rgba(0,0,0,0.5);
        pointer-events: none;
        opacity: 0;
        transform: scale(0.5);
        transition: none;
        z-index: 20;
    }

    .ac-extra-overlay.visible {
        opacity: 1;
        animation: ac-count-pulse 1.1s ease-in-out infinite;
    }

    /* In Box overlay — même structure qu'Extra, en bleu */
    .ac-inbox-overlay {
        position: absolute;
        left: 0;
        right: 0;
        top: 18%;
        text-align: center;
        font-family: 'Poppins', sans-serif;
        font-weight: 800;
        font-size: 13.3cqh;
        line-height: 1;
        letter-spacing: 0.5px;
        color: #3b82f6;
        -webkit-text-stroke: 2px #000;
        paint-order: stroke fill;
        text-shadow:
            0 3px 8px rgba(0,0,0,0.65),
            0 0 14px rgba(0,0,0,0.5);
        pointer-events: none;
        opacity: 0;
        transform: scale(0.5);
        transition: none;
        z-index: 20;
    }

    .ac-inbox-overlay.visible {
        opacity: 1;
        animation: ac-count-pulse 1.1s ease-in-out infinite;
    }

    /* Drapeau langue — à gauche, sous le count, même taille qu'Extra */
    .ac-flag-overlay {
        position: absolute;
        left: 22%;
        top: 72%;
        pointer-events: none;
        opacity: 0;
        transform: scale(0.5);
        transition: none;
        z-index: 20;
    }

    .ac-flag-overlay .fi {
        display: block;
        box-sizing: border-box;
        width: 18cqh;
        height: 13.3cqh;
        font-size: 0;
        border: 2px solid #000;
        border-radius: 4px;
        box-shadow:
            0 4px 10px rgba(0,0,0,0.6),
            0 0 14px rgba(0,0,0,0.5);
        background-size: cover;
        background-position: center;
    }

    .ac-flag-overlay.visible {
        opacity: 1;
        animation: ac-count-pulse 1.1s ease-in-out infinite;
    }

    /* Condition — à droite, sous le count, même dimensions externes que le flag */
    .ac-cond-overlay {
        position: absolute;
        right: 22%;
        top: 72%;
        width: 18cqh;
        height: 13.3cqh;
        pointer-events: none;
        opacity: 0;
        transform: scale(0.5);
        transition: none;
        z-index: 20;
        filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6));
    }

    .ac-cond-overlay .condition-badge {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        border: 2px solid #000 !important;
        border-radius: 4px !important;
        line-height: 1 !important;
    }

    .ac-cond-overlay.visible {
        opacity: 1;
        animation: ac-count-pulse 1.1s ease-in-out infinite;
    }

    /* Foil auto sweep — gradient 135° qui traverse la carte en diagonale.
       Avec background-size 300% 300% on positionne le centre lumineux du
       gradient hors carte aux deux extrêmes ; l'animation interpole
       background-position pour faire glisser la bande en diagonale. */
    .ac-foil-wrap {
        position: relative;
        width: 100%;
        aspect-ratio: 5 / 7;
        overflow: hidden;
    }

    .ac-foil-wrap .card-image {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }

    .ac-foil-wrap::before,
    .ac-foil-wrap::after {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        background-size: 300% 300%;
        background-repeat: no-repeat;
        will-change: background-position;
        animation: ac-foil-sweep 3.5s ease-in-out infinite alternate;
    }

    .ac-foil-wrap { --ac-foil-opacity: 1; }
    .ac-foil-wrap::before { opacity: calc(0.65 * var(--ac-foil-opacity)); }
    .ac-foil-wrap::after  { opacity: calc(0.35 * var(--ac-foil-opacity)); }

    /* Décalage cyclique d'une carte à l'autre via le :nth-child du wrapper
       parent — donne l'impression que chaque carte vit son propre rythme. */
    :nth-child(8n+1) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+1) > * > .compact-card .ac-foil-wrap::after { animation-delay: -0.0s; }
    :nth-child(8n+2) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+2) > * > .compact-card .ac-foil-wrap::after { animation-delay: -0.4s; }
    :nth-child(8n+3) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+3) > * > .compact-card .ac-foil-wrap::after { animation-delay: -0.9s; }
    :nth-child(8n+4) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+4) > * > .compact-card .ac-foil-wrap::after { animation-delay: -1.5s; }
    :nth-child(8n+5) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+5) > * > .compact-card .ac-foil-wrap::after { animation-delay: -2.1s; }
    :nth-child(8n+6) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+6) > * > .compact-card .ac-foil-wrap::after { animation-delay: -2.6s; }
    :nth-child(8n+7) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+7) > * > .compact-card .ac-foil-wrap::after { animation-delay: -3.1s; }
    :nth-child(8n+8) > * > .compact-card .ac-foil-wrap::before,
    :nth-child(8n+8) > * > .compact-card .ac-foil-wrap::after { animation-delay: -3.4s; }

    @keyframes ac-foil-sweep {
        0%   { background-position: 100% 100%; }
        100% { background-position: 0% 0%; }
    }

    .ac-foil-wrap::before {
        background-image: linear-gradient(135deg,
            transparent 0%,
            hsl(0,80%,70%)   18%,
            hsl(60,80%,70%)  32%,
            hsl(120,80%,70%) 50%,
            hsl(200,80%,70%) 68%,
            hsl(280,80%,70%) 82%,
            transparent 100%
        );
        filter: brightness(0.95) contrast(1.4);
        mix-blend-mode: color-dodge;
        z-index: 2;
    }

    .ac-foil-wrap::after {
        background-image: linear-gradient(135deg,
            transparent 0%,
            rgba(255,255,255,0.3) 40%,
            rgba(255,255,255,0.85) 50%,
            rgba(255,255,255,0.3) 60%,
            transparent 100%
        );
        mix-blend-mode: overlay;
        z-index: 3;
    }


    .compact-card .card-footer {
        padding: 6px 8px;
        background: linear-gradient(180deg, rgba(55, 65, 81, 0.9) 0%, rgba(45, 55, 70, 0.95) 100%);
    }

    .compact-card .card-name {
        font-size: 0.7rem;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #fff;
        margin-bottom: 4px;
    }

    .compact-card .card-name-link {
        color: inherit;
        text-decoration: none;
    }

    .compact-card .card-name-link:hover {
        text-decoration: underline;
        color: #d4a90f;
    }

    .compact-card-wrapper:focus .compact-card,
    .compact-card-wrapper.focused .compact-card {
        overflow: visible;
    }

    .compact-card-wrapper:focus .card-footer,
    .compact-card-wrapper.focused .card-footer {
        position: absolute;
        left: 0;
        right: 0;
        overflow: hidden;
        background: linear-gradient(180deg, rgba(55, 65, 81, 0.95) 0%, rgba(45, 55, 70, 0.98) 100%);
        box-shadow: 0 0 0 3px var(--mud-palette-primary);
        border-radius: 0 0 8px 8px;
        padding: 6px 8px;
    }

    .compact-card-wrapper:focus .card-name,
    .compact-card-wrapper.focused .card-name {
        white-space: normal;
        text-overflow: unset;
        overflow: visible;
    }

    .compact-card .card-count {
        font-weight: 700;
        color: #4caf50;
    }

    .compact-card .card-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
        margin-bottom: 4px;
    }

    .compact-card .fi {
        font-size: 0.85rem;
        line-height: 1;
        border-radius: 2px;
    }

    .compact-card .cond-badge {
        font-size: 0.65rem;
    }

    .compact-card .count-badge {
        font-size: 0.6rem;
        background: var(--opaps-gold, #b9900b);
        color: #fff;
        padding: 1px 3px;
        border-radius: 3px;
    }

    .compact-card .card-price {
        font-size: 0.75rem;
        font-weight: 600;
        color: #4caf50;
    }

    .compact-card .card-warning {
        position: absolute;
        top: 4px;
        right: 4px;
        background: rgba(255, 152, 0, 0.9);
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.7rem;
    }

    .card-with-marker {
        display: flex;
        align-items: flex-start;
    }

    .expansion-marker {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        padding-top: 30px;
        flex-shrink: 0;
    }

    .expansion-marker svg {
        width: 24px;
        height: 20px;
        fill: var(--text-muted) !important;
    }

    .expansion-marker svg * {
        fill: var(--text-muted) !important;
    }
