/* Responsive : page prestations (fenêtre étroite → large). Tout est scopé body.embed. */
body.embed #page-prestations-v2{--rp-gap:clamp(10px,1.6vw,18px);min-width:0;max-width:100%;overflow-x:clip}
body.embed #page-prestations-v2 .pg-head{gap:var(--rp-gap);margin-bottom:clamp(10px,1.5vw,16px)}
body.embed #page-prestations-v2 .pg-head>div{flex:1 1 320px;min-width:0}
body.embed #page-prestations-v2 .pg-title{font-size:clamp(17px,1.2vw + 12px,22px);overflow-wrap:anywhere}
body.embed #page-prestations-v2 .pg-sub{max-width:min(760px,100%)}
body.embed #page-prestations-v2 #btn-new-prestation-v2{min-height:38px;flex:0 0 auto}

/* Barre d'outils */
body.embed #page-prestations-v2 .toolbar-card{container-type:inline-size;padding:clamp(8px,1vw,14px)}
body.embed #page-prestations-v2 .filters-row{gap:8px 10px}
body.embed #page-prestations-v2 #ptv2-search{flex:1 1 260px;min-width:min(220px,100%);min-height:38px}
body.embed #page-prestations-v2 #btn-refresh-prestations-v2{min-height:38px;white-space:nowrap}

/* Tableau : hauteur adaptée à la fenêtre, pas de débordement */
body.embed #page-prestations-v2 .table-card{container-type:inline-size;container-name:ptv2;max-width:100%;max-height:max(280px,calc(100vh - 250px));overflow:auto}
body.embed #page-prestations-v2 #ptv2-table{min-width:0;table-layout:auto}
body.embed #page-prestations-v2 #ptv2-table td{overflow-wrap:anywhere;min-width:0}
body.embed #page-prestations-v2 #ptv2-table .ptv2-c-nom{font-weight:600;min-width:140px}
body.embed #page-prestations-v2 #ptv2-table .ptv2-c-temps,body.embed #page-prestations-v2 #ptv2-table .ptv2-c-taux{white-space:nowrap;font-variant-numeric:tabular-nums}
body.embed #page-prestations-v2 #ptv2-table .ptv2-c-links{white-space:nowrap}
body.embed #page-prestations-v2 #ptv2-table .btn{min-height:36px}
body.embed #page-prestations-v2 #ptv2-tbody .btn-edit-ptv2{min-width:36px;width:36px}
body.embed #page-prestations-v2 #ptv2-tbody .btn-show-links{min-width:36px}

/* Moyen : on retire la colonne Type MO (info secondaire, visible dans la fenêtre de modification) */
@container ptv2 (max-width:860px){
  body.embed #page-prestations-v2 #ptv2-table th:nth-child(4),
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-mo{display:none}
  body.embed #page-prestations-v2 #ptv2-table th,body.embed #page-prestations-v2 #ptv2-table td{padding-inline:10px}
}
/* Étroit : chaque prestation devient une carte */
@container ptv2 (max-width:680px){
  body.embed #page-prestations-v2 #ptv2-table,
  body.embed #page-prestations-v2 #ptv2-table tbody{display:block;width:100%}
  body.embed #page-prestations-v2 #ptv2-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
  body.embed #page-prestations-v2 #ptv2-table tbody{padding:8px;display:grid;gap:8px}
  body.embed #page-prestations-v2 #ptv2-table tr[data-nom]{display:grid;grid-template-columns:auto auto auto 1fr auto;grid-template-areas:"nom nom nom nom edit" "des des des des des" "temps mo taux . ." "links links links links links";gap:2px 14px;padding:10px 12px;border:1px solid var(--border);border-radius:var(--radius-sm,8px);background:var(--card)}
  body.embed #page-prestations-v2 #ptv2-table tr[data-nom] td{display:block;border:0;padding:2px 0;background:none!important}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-nom{grid-area:nom;align-self:center;font-size:15px}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-edit{grid-area:edit}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-des{grid-area:des;color:var(--sub)}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-des:empty{display:none}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-links{grid-area:links;padding-top:6px}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-links .btn{width:100%}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-temps{grid-area:temps}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-mo{grid-area:mo;display:block}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-taux{grid-area:taux}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-temps,body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-mo,body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-taux{font-size:13px}
  body.embed #page-prestations-v2 #ptv2-table td[data-label]:not(:empty)::before{content:attr(data-label) " : ";color:var(--sub);font-size:12px}
  body.embed #page-prestations-v2 #ptv2-table td.ptv2-c-des::before{content:none!important}
  body.embed #page-prestations-v2 #ptv2-table tr:has(td.pcm-empty){display:table-row}
  body.embed #page-prestations-v2 #ptv2-tbody .pcm-empty{display:block!important}
}

/* Panneau produits liés */
body.embed #page-prestations-v2 #ptv2-link-panel{container-type:inline-size;padding:clamp(12px,1.6vw,20px);margin-top:var(--rp-gap);max-width:100%}
body.embed #page-prestations-v2 #ptv2-link-title{overflow-wrap:anywhere;font-size:clamp(15px,.6vw + 12px,17px)}
body.embed #page-prestations-v2 #ptv2-link-panel .cart-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,300px),1fr));gap:8px}
body.embed #page-prestations-v2 #ptv2-link-panel .cart-list>p{grid-column:1/-1}
body.embed #page-prestations-v2 #ptv2-link-panel .cart-item{min-width:0;align-items:center;gap:10px;min-height:44px}
body.embed #page-prestations-v2 #ptv2-link-panel .cart-item>span{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}
body.embed #page-prestations-v2 #ptv2-link-panel .cart-item .btn{flex:0 0 auto;min-height:36px;min-width:36px;white-space:nowrap}
body.embed #page-prestations-v2 #ptv2-link-panel .chip-remove{width:36px}
body.embed #page-prestations-v2 #ptv2-link-search{min-height:38px}
body.embed #page-prestations-v2 #ptv2-link-results{max-height:min(260px,40vh)!important}
@container (max-width:420px){
  body.embed #page-prestations-v2 #ptv2-link-panel .cart-list{grid-template-columns:1fr}
}

/* Fenêtre modale */
body.embed #prestation-v2-modal .modal{width:min(720px,calc(100vw - 24px));max-width:none;max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);overflow:auto;padding:clamp(14px,2vw,24px);container-type:inline-size}
body.embed #prestation-v2-modal .form-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:12px clamp(10px,1.6vw,16px)}
body.embed #prestation-v2-modal .form-grid label:first-child,
body.embed #prestation-v2-modal .form-grid label:nth-child(2){grid-column:1/-1}
body.embed #prestation-v2-modal .input{min-height:38px;width:100%;min-width:0}
body.embed #prestation-v2-modal .modal-actions{flex-wrap:wrap;gap:8px;bottom:calc(-1 * clamp(14px,2vw,24px));padding-bottom:clamp(14px,2vw,24px);margin-bottom:calc(-1 * clamp(14px,2vw,24px));z-index:2}
body.embed #prestation-v2-modal .modal-actions .btn{min-height:38px}
@container (max-width:420px){
  body.embed #prestation-v2-modal .modal-actions .btn{flex:1 1 40%}
  body.embed #prestation-v2-modal #btn-delete-prestation-v2{flex-basis:100%;margin-right:0;order:3}
}
@media (max-height:640px){
  body.embed #page-prestations-v2 .toolbar-card{position:static}
  body.embed #page-prestations-v2 .table-card{max-height:none}
}
@media (max-width:760px){
  body.embed #page-prestations-v2 .toolbar-card{position:sticky}
}
