/* Modale produit + comparateur marchands (idees cadeaux CN), design Geek Planet.
   Inter est deja auto-hebergee par cn-ap-cards.css (dependance d'enqueue). */

.cn-apm-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 7, 18, .72);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    -webkit-font-smoothing: antialiased;
}

.cn-apm-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.cn-apm-overlay,
.cn-apm-overlay * {
    box-sizing: border-box;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif !important;
}

.cn-apm-panel {
    position: relative;
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
    transform: translateY(16px) scale(.98);
    transition: transform .25s ease;
    padding: 24px;
}

.cn-apm-overlay.is-open .cn-apm-panel {
    transform: none;
}

.cn-apm-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease;
    z-index: 2;
}

.cn-apm-close:hover {
    background: #e5e7eb;
}

/* --- En-tete produit : image + infos --- */
.cn-apm-head {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.cn-apm-imgwrap {
    flex: 0 0 200px;
    width: 200px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #f3f4f6;
    border-radius: 12px;
    padding: 8px;
}

.cn-apm-imgwrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cn-apm-info {
    flex: 1 1 auto;
    min-width: 0;
}

.cn-apm-brand {
    display: inline-block;
    margin: 0 0 8px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #4b5563;
    background: #f3f4f6;
    border-radius: 9999px;
}

.cn-apm-title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.35;
    color: #111827;
}

.cn-apm-price-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 6px;
}

.cn-apm-price-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.cn-apm-price {
    font-size: 26px;
    font-weight: 900;
    font-style: italic;
    color: #111827;
}

.cn-apm-price sup {
    font-size: .6em;
    font-weight: 400;
    color: #6b7280;
    line-height: 0;
    position: relative;
    top: -.6em;
    margin-left: 2px;
    font-style: normal;
}

/* --- Mini graphe de tendance --- */
.cn-apm-updated {
    margin: 6px 0 0;
    font-size: 12px;
    color: #6b7280;
}

.cn-apm-hist {
    margin: 14px 0 0;
    padding: 14px;
    background: #f9fafb;
    border: 1px solid #eef0f2;
    border-radius: 12px;
}

.cn-apm-hist-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cn-apm-hist-title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
}

.cn-apm-trend-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
}

.cn-apm-trend-badge.down { color: #15803d; background: #dcfce7; }
.cn-apm-trend-badge.up   { color: #b91c1c; background: #fee2e2; }
.cn-apm-trend-badge.flat { color: #6b7280; background: #f3f4f6; }

.cn-apm-spark {
    display: block;
    width: 100%;
    height: 64px;
}

.cn-apm-hist-dates {
    display: flex;
    justify-content: space-between;
    margin: 4px 2px 0;
    font-size: 11px;
    color: #9ca3af;
}

.cn-apm-hist-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.cn-apm-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #eef0f2;
    border-radius: 8px;
    text-align: center;
}

.cn-apm-stat-l {
    font-size: 11px;
    color: #6b7280;
}

.cn-apm-stat-v {
    font-size: 15px;
    font-weight: 800;
    color: #111827;
}

.cn-apm-stat-v sup { font-size: .65em; font-weight: 400; color: #6b7280; }

.cn-apm-hist-note {
    margin: 10px 0 0;
    font-size: 11px;
    line-height: 1.5;
    color: #9ca3af;
}

/* --- Comparateur marchands --- */
.cn-apm-compare {
    margin: 20px 0 0;
}

.cn-apm-compare-h {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.cn-apm-compare-h .cn-apm-count {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 9999px;
}

.cn-apm-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr .9fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 8px;
    background: #fff;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.cn-apm-row.best {
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, .15);
}

.cn-apm-row.out {
    opacity: .55;
}

.cn-apm-merchant {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.cn-apm-merchant img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex: 0 0 auto;
}

/* Wordmark marchand (Fnac...) : logo horizontal, remplace le nom texte. */
.cn-apm-merchant img.cn-apm-wordmark {
    width: auto;
    max-width: 92px;
    height: 26px;
    border-radius: 3px;
}

.cn-apm-mcol {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.cn-apm-merchant-name {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cn-apm-best-tag {
    display: block;
    margin-top: 1px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #15803d;
}

.cn-apm-cell-total {
    font-size: 18px;
    font-weight: 900;
    font-style: italic;
    color: #111827;
    text-align: center;
}

.cn-apm-cell-total sup {
    font-size: .6em;
    font-weight: 400;
    font-style: normal;
    color: #6b7280;
    position: relative;
    top: -.6em;
    margin-left: 1px;
}

.cn-apm-cell-ship {
    font-size: 12px;
    text-align: center;
    color: #6b7280;
}

.cn-apm-cell-ship.free {
    color: #15803d;
    font-weight: 700;
    text-transform: uppercase;
}

.cn-apm-buy {
    display: inline-block;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 700;
    font-style: italic;
    color: #fff;
    white-space: nowrap;
    background: oklch(78.71% .1616 153.72);
    border: 0;
    border-radius: 9999px;
    cursor: pointer;
    transition: all .2s ease;
}

.cn-apm-buy:hover {
    background: oklch(56.71% .1629 148.3);
    box-shadow: 0 0 0 4px rgba(21, 128, 61, .2);
}

.cn-apm-note {
    margin: 14px 0 0;
    font-size: 11px;
    line-height: 1.5;
    color: #9ca3af;
    text-align: center;
}

/* --- Etats chargement / erreur --- */
.cn-apm-state {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.cn-apm-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 14px;
    border: 3px solid #e5e7eb;
    border-top-color: #4ade80;
    border-radius: 9999px;
    animation: cn-apm-spin .8s linear infinite;
}

@keyframes cn-apm-spin { to { transform: rotate(360deg); } }

/* --- Bouton (i) sur les cards --- */
.cn-ap-card-price {
    position: relative;
}

.cn-ap-info {
    width: 26px;
    height: 26px;
    margin-left: 4px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    background: #f9fafb;
    color: #6b7280;
    cursor: pointer;
    vertical-align: middle;
    transition: all .2s ease;
}

.cn-ap-info svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.cn-ap-info:hover {
    color: #111827;
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .cn-apm-panel { padding: 18px; }
    .cn-apm-head { flex-direction: column; align-items: center; text-align: center; }
    .cn-apm-imgwrap { flex-basis: 160px; width: 160px; }
    .cn-apm-price-row { justify-content: center; }
    .cn-apm-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: 'merchant total' 'ship buy';
        row-gap: 8px;
    }
    .cn-apm-merchant { grid-area: merchant; }
    .cn-apm-cell-total { grid-area: total; text-align: right; }
    .cn-apm-cell-ship { grid-area: ship; text-align: left; }
    .cn-apm-buy { grid-area: buy; justify-self: end; }
}
