/* Responsive : page prix (fenêtre étroite → large). Tout est scopé body.embed. */

body.embed #page-prix .pg-sub { max-width: 78ch; }
body.embed #page-prix .pg-title { overflow-wrap: anywhere; }

/* ---- barre d'outils : recherche + boutons, retour à la ligne propre ---- */
body.embed #page-prix .toolbar-card { position: sticky; top: 0; z-index: 5; padding: clamp(10px, 1.4vw, 16px); }
body.embed #page-prix .filters-row { gap: 8px; }
body.embed #page-prix #prix-search { flex: 1 1 260px; min-width: 0; min-height: 38px; }
body.embed #page-prix .filters-row .btn { flex: 0 0 auto; min-height: 38px; white-space: nowrap; }
@media (max-width: 900px) {
  body.embed #page-prix .filters-row .btn { flex: 1 1 200px; white-space: normal; }
  body.embed #page-prix #prix-search { flex-basis: 100%; }
}
@media (max-height: 700px) {
  body.embed #page-prix .toolbar-card { position: static; }
}

/* ---- tableau ---- */
body.embed #page-prix .table-card { container-type: inline-size; container-name: prixtbl; overflow-x: auto; }
body.embed #page-prix #prix-table { min-width: 0; table-layout: auto; }
body.embed #page-prix #prix-table th,
body.embed #page-prix #prix-table td { padding: 10px clamp(8px, 1.2cqw, 14px); vertical-align: middle; }
body.embed #page-prix #prix-table td:nth-child(3),
body.embed #page-prix #prix-table td:nth-child(4) { overflow-wrap: anywhere; }
body.embed #page-prix #prix-table td:nth-child(4) { min-width: 160px; }
body.embed #page-prix #prix-table .prix-achat-input { min-height: 36px; width: clamp(72px, 9cqw, 100px) !important; }
body.embed #page-prix #prix-table .prix-marge-input { min-height: 36px; width: clamp(64px, 7cqw, 84px) !important; }
body.embed #page-prix #prix-table td:last-child { white-space: nowrap; }
body.embed #page-prix #prix-table td:last-child .icon-btn { width: 36px; height: 36px; font-size: 15px; margin-right: 2px; }
body.embed #page-prix #prix-table td:nth-child(2) { max-width: 16ch; overflow-wrap: anywhere; }
body.embed #page-prix #prix-table td:nth-child(8) { white-space: nowrap; }

/* intermédiaire : on retire « Dernière modif. » puis la référence */
@container prixtbl (max-width: 1000px) {
  body.embed #page-prix #prix-table th:nth-child(8), #page-prix #prix-table td:nth-child(8) { display: none; }
}
@container prixtbl (max-width: 860px) {
  body.embed #page-prix #prix-table th:nth-child(3), #page-prix #prix-table td:nth-child(3) { display: none; }
}

/* étroit : chaque produit devient une carte */
@container prixtbl (max-width: 700px) {
  body.embed #page-prix #prix-table, #page-prix #prix-table tbody { display: block; width: 100%; }
  body.embed #page-prix #prix-table thead { display: none; }
  body.embed #page-prix #prix-table tbody tr {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: 10px; row-gap: 6px;
    align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border);
  }
  body.embed #page-prix #prix-table tbody tr:last-child { border-bottom: 0; }
  body.embed #page-prix #prix-table tbody td, #page-prix #prix-table tbody tr:hover td {
    display: block; padding: 0; border: 0; background: transparent; max-width: none; min-width: 0;
  }
  body.embed #page-prix #prix-table td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  body.embed #page-prix #prix-table td:nth-child(2) { grid-column: 2 / span 3; grid-row: 1; font-weight: 600; }
  body.embed #page-prix #prix-table td:nth-child(3) { display: block; grid-column: 5 / span 2; grid-row: 1; text-align: right; }
  body.embed #page-prix #prix-table td:nth-child(4) { grid-column: 2 / -1; grid-row: 2; min-width: 0; }
  body.embed #page-prix #prix-table td:nth-child(5) { grid-column: 1 / span 2; grid-row: 3; }
  body.embed #page-prix #prix-table td:nth-child(6) { grid-column: 3 / span 2; grid-row: 3; }
  body.embed #page-prix #prix-table td:nth-child(7) { grid-column: 5 / span 2; grid-row: 3; text-align: right; font-weight: 600; }
  body.embed #page-prix #prix-table td:nth-child(8) { display: block; grid-column: 1 / span 4; grid-row: 4; align-self: center; }
  body.embed #page-prix #prix-table td:nth-child(9) { grid-column: 5 / span 2; grid-row: 4; text-align: right; }
  body.embed #page-prix #prix-table td:nth-child(5)::before,
  body.embed #page-prix #prix-table td:nth-child(6)::before,
  body.embed #page-prix #prix-table td:nth-child(7)::before {
    display: block; font-size: 11px; font-weight: 600; color: var(--sub); margin-bottom: 3px; text-align: inherit;
  }
  body.embed #page-prix #prix-table td:nth-child(5)::before { content: "Prix d'achat (€)"; }
  body.embed #page-prix #prix-table td:nth-child(6)::before { content: "Coefficient"; }
  body.embed #page-prix #prix-table td:nth-child(7)::before { content: "Prix de vente HT"; }
  body.embed #page-prix #prix-table td:nth-child(8)::before { content: "Modifié : "; color: var(--sub); }
  body.embed #page-prix #prix-table .prix-achat-input,
  body.embed #page-prix #prix-table .prix-marge-input { width: 100% !important; }
  /* ligne « aucun résultat » */
  body.embed #page-prix #prix-table tbody tr:has(> td[colspan]) { display: block; }
  body.embed #page-prix #prix-table td[colspan] { padding: 16px 0; }
  body.embed #page-prix #prix-table td[colspan]::before { content: none; }
}
@container prixtbl (max-width: 460px) {
  body.embed #page-prix #prix-table td:nth-child(5) { grid-column: 1 / span 3; }
  body.embed #page-prix #prix-table td:nth-child(6) { grid-column: 4 / span 3; }
  body.embed #page-prix #prix-table td:nth-child(7) { grid-column: 1 / span 6; grid-row: 4; text-align: left; }
  body.embed #page-prix #prix-table td:nth-child(8) { grid-row: 5; grid-column: 1 / span 4; }
  body.embed #page-prix #prix-table td:nth-child(9) { grid-row: 5; grid-column: 5 / span 2; }
}

/* ---- fenêtres modales (hors #page-prix) : tiennent dans la fenêtre ---- */
body.embed #prix-sites-modal, body.embed #prix-evolution-modal, body.embed #marques-evolution-modal { padding: 12px; }
body.embed #prix-sites-modal .modal,
body.embed #prix-evolution-modal .modal,
body.embed #marques-evolution-modal .modal {
  width: min(960px, 100%); max-width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(14px, 2.4vw, 24px);
}
body.embed #prix-sites-modal .modal-actions,
body.embed #prix-evolution-modal .modal-actions,
body.embed #marques-evolution-modal .modal-actions {
  position: sticky; bottom: calc(-1 * clamp(14px, 2.4vw, 24px)); background: var(--card);
  margin: 10px calc(-1 * clamp(14px, 2.4vw, 24px)) calc(-1 * clamp(14px, 2.4vw, 24px));
  padding: 10px clamp(14px, 2.4vw, 24px); border-top: 1px solid var(--border);
}
body.embed #prix-sites-modal .btn, body.embed #prix-evolution-modal .btn, body.embed #marques-evolution-modal .btn { min-height: 38px; }
body.embed #prix-sites-list { max-height: max(160px, calc(100dvh - 330px)) !important; overscroll-behavior: contain; }
body.embed #mev-chart-box { max-height: max(160px, calc(100dvh - 340px)) !important; overscroll-behavior: contain; }
body.embed #prix-sites-modal .prix-site-row { padding: 10px 12px; }
body.embed #prix-sites-modal .prix-site-url-input { min-height: 38px; text-overflow: ellipsis; }
body.embed #prix-sites-modal .prix-site-row .name { overflow-wrap: anywhere; font-size: 13px; }
body.embed #prix-evolution-modal #pev-title { overflow-wrap: anywhere; }
body.embed #prix-evolution-modal .sg-direction-choice label,
body.embed #marques-evolution-modal .sg-direction-choice label { min-height: 36px; padding-right: 4px; }
body.embed #prix-evolution-modal .sg-direction-choice,
body.embed #marques-evolution-modal .sg-direction-choice { font-size: 13px; flex-wrap: wrap; }

/* graphiques SVG : fluides, lisibles quand ils rétrécissent */
body.embed #pev-chart-box { min-width: 0; }
body.embed #pev-chart-box .pev-svg { display: block; min-height: 170px; max-height: calc(100dvh - 380px); }
body.embed .pev-axis-label { font-size: clamp(10px, 1.6vw, 12px); }
body.embed .pev-point-label { font-size: clamp(11px, 1.8vw, 13px); }

/* barres par marque : la ligne s'empile sous 560 px */
body.embed .mev-marque { flex: 0 0 clamp(90px, 22%, 170px); white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
body.embed .mev-row { min-height: 32px; }
body.embed .mev-value { flex: 0 0 clamp(64px, 12%, 84px); }
@media (max-width: 560px) {
  body.embed .mev-row { flex-wrap: wrap; row-gap: 2px; }
  body.embed .mev-marque { flex: 1 1 60%; white-space: normal; }
  body.embed .mev-value { flex: 0 0 auto; margin-left: auto; }
  body.embed .mev-bar-track { flex: 1 1 100%; order: 3; }
}
