/* E-Matrice 1.0.1 — socle responsive global
   Objectif : desktop, tablette, mobile, petits portables et écrans tactiles. */
:root{--em-touch:44px}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
html,body{max-width:100%} body{overflow-x:hidden}
*,*::before,*::after{box-sizing:border-box}
img,video{max-width:100%;height:auto} svg{max-width:100%}
iframe{max-width:100%}
input,select,textarea,button{max-width:100%}
.flex-fill,.flex-grow-1,[class*="col-"]{min-width:0}
.container,.container-fluid,.page-container,.main-container,.shell{min-width:0}
.table-responsive,.table-container,.table-wrapper,.table-scroll,.data-table-wrap{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:thin}
.table-responsive table,.table-container table,.table-wrapper table{margin-bottom:0}
.modal{padding-left:0!important;padding-right:0!important}
.modal-dialog{max-width:calc(100vw - 24px);margin-left:auto;margin-right:auto}
.modal-dialog-scrollable .modal-content{max-height:calc(100dvh - 24px)}
.modal-body{min-width:0;overflow-wrap:anywhere}
.dropdown-menu{max-width:calc(100vw - 16px)}
.navbar,.topbar,.top,.page-header,.header-toolbar,.card-header,.table-toolbar{min-width:0}
.navbar-collapse{min-width:0}
.nav-tabs,.nav-pills{max-width:100%;overflow-x:auto;overflow-y:hidden;flex-wrap:nowrap;-webkit-overflow-scrolling:touch;scrollbar-width:thin}
.nav-tabs .nav-link,.nav-pills .nav-link{white-space:nowrap}
.form-control,.form-select{min-width:0}
.btn,button,a.btn{min-height:var(--em-touch)}

/* Cartographie / espace de gestion */
@media (max-width:980px){
  .map-management{left:8px!important;right:8px!important;top:auto!important;bottom:8px!important;width:auto!important;max-width:none!important;height:min(78dvh,760px)!important;max-height:calc(100dvh - 16px)!important;transform:none!important}
  .map-management.fullscreen,.map-management.table-fullscreen{inset:6px!important;height:auto!important;max-height:none!important}
  .mgmt-head{cursor:default!important}
  .mgmt-search{min-width:100%!important;max-width:none!important;flex-basis:100%!important}
  .mgmt-select{flex:1 1 150px!important;min-width:0!important}
  .mgmt-filters{align-items:stretch!important}
  .mgmt-body{grid-template-columns:minmax(0,1fr)!important}
  .mgmt-detail{display:block!important;max-width:100%!important;min-width:0!important}
  .mgmt-tabs{overflow-x:auto!important;-webkit-overflow-scrolling:touch}
}
@media (max-width:760px){
  .topbar{gap:6px!important}
  .topbar .global-search{min-width:0!important;flex:1 1 160px!important}
  .topnav{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}
  .topnav::-webkit-scrollbar{display:none}
  .userchip .usertext{display:none!important}
  .toolbar-shell{max-width:calc(100vw - 16px)!important}
  .toolbar{overflow-x:auto!important;overflow-y:hidden!important;-webkit-overflow-scrolling:touch}
  .sidebar,.rightbar{max-width:calc(100vw - 16px)!important}
  .mgmt-row-actions{min-width:0!important}
  .mgmt-frame-modal{padding:6px!important}
  .mgmt-frame-shell{width:100%!important;height:calc(100dvh - 12px)!important;border-radius:var(--dgid-radius-md,12px) !important}
}

/* Statistiques & rapports */
@media (max-width:850px){
  .stats-filter-grid{grid-template-columns:1fr 1fr!important}
  .stats-filter-actions{grid-column:1/-1!important;display:flex!important}
  .stats-filter-actions>*{flex:1 1 auto}
  .hero,.hero-actions{min-width:0}
  .hero-actions{flex-wrap:wrap!important}
}
@media (max-width:560px){
  .stats-filter-grid{grid-template-columns:1fr!important}
  .stats-filter-actions{grid-column:auto!important;flex-direction:column!important}
  .report-dialog{width:calc(100vw - 12px)!important;max-height:calc(100dvh - 12px)!important;border-radius:var(--dgid-radius-lg,16px) !important}
  .report-body{padding:14px!important}
  .report-head{padding:14px!important}
  .report-actions{flex-direction:column-reverse!important}
  .report-actions>*{width:100%!important}
}

/* Opérations foncières */
@media (max-width:900px){
  .op-stepper,.op-stepper-five{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .op-step::after{display:none!important}
  .operation-point-map{height:52dvh!important;min-height:320px!important}
  .sticky-footer{position:static!important}
}
@media (max-width:576px){
  .op-stepper,.op-stepper-five{grid-template-columns:1fr!important}
  .point-result-row .row>*{width:100%!important;max-width:100%!important;flex:0 0 100%!important}
  .source-coordinate-summary{display:grid!important;grid-template-columns:1fr!important}
  .operation-point-map{height:46dvh!important;min-height:280px!important}
}

/* Formulaires */
@media (max-width:768px){
  .row.g-3>[class*="col-"],.row.g-4>[class*="col-"]{min-width:0}
  .input-group{flex-wrap:wrap}
  .input-group>.form-control,.input-group>.form-select{min-width:0}
  .form-actions,.action-buttons,.button-group{flex-wrap:wrap!important}
  .form-actions>.btn,.action-buttons>.btn{flex:1 1 180px}
  .select2-container{width:100%!important;max-width:100%!important}
}

/* Import / prévisualisation */
@media (max-width:768px){
  .preview-table th.map-cell,.preview-table td.map-cell{width:260px!important;min-width:260px!important}
  .preview-table{min-width:760px}
  .preview-wrapper,.preview-table-wrap{overflow-x:auto!important;-webkit-overflow-scrolling:touch}
}

/* Cartes de détail */
@media (max-width:576px){
  #prop-map,#propsMap,.map-container{min-height:280px!important;max-height:58dvh}
  .gm-style .gm-style-iw-c{max-width:calc(100vw - 40px)!important}
  .gm-style .gm-style-iw-d{max-width:calc(100vw - 52px)!important}
}

/* Très petits écrans */
@media (max-width:390px){
  body{font-size:14px}
  .container,.container-fluid,.main-container,.page-container,.shell{padding-left:10px!important;padding-right:10px!important}
  .btn,button,a.btn{font-size:.9rem}
  .modal-dialog{max-width:calc(100vw - 10px);margin:5px auto}
}

/* Orientation paysage mobile / tablette basse */
@media (max-height:560px) and (orientation:landscape){
  .modal-dialog-scrollable .modal-content{max-height:calc(100dvh - 8px)}
  .operation-point-map{height:58dvh!important;min-height:220px!important}
  .sidebar,.rightbar{top:4px!important;bottom:4px!important;max-height:calc(100% - 8px)!important}
  .map-management{height:88dvh!important;bottom:4px!important}
}

/* Dashboards institutionnels et listes */
@media (max-width:1100px){
  .workspace{grid-template-columns:minmax(0,1fr)!important}
  .sidecard,.side-card,.detail-panel{max-width:100%!important}
  .filters{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}
@media (max-width:620px){
  .filters{grid-template-columns:1fr!important}
  .headrow,.top,.page-header,.header-toolbar,.table-toolbar{flex-wrap:wrap!important}
  .actions{width:100%;flex-wrap:wrap!important}
  .actions>.btn{flex:1 1 150px}
}

/* Drawers / panneaux latéraux */
.object-drawer{max-width:calc(100vw - 8px)!important;height:100dvh!important}
@media(max-width:576px){
  .object-drawer{width:100vw!important;max-width:100vw!important}
  .drawer-body,.object-drawer .card-body{overflow-y:auto;-webkit-overflow-scrolling:touch}
}

/* Cartes intégrées et contrôles flottants */
@media(max-width:576px){
  .map-control{left:12px!important;right:12px!important;width:auto!important;max-width:none!important}
  .map-alerts{left:12px!important;right:12px!important;max-width:none!important}
  .map-alerts>*{max-width:100%!important}
  .map-legend{max-width:calc(100% - 24px)!important;max-height:38%;overflow:auto!important}
  .toast-notification,.eml-toast{left:10px!important;right:10px!important;top:10px!important;max-width:none!important}
}

/* Graphiques */
.chart-container,.chart-wrap,.chart-card canvas{max-width:100%!important}
canvas{max-width:100%!important}
@media(max-width:576px){
  .chart-container{height:280px!important;min-height:240px}
}

/* Barre de navigation / pied de page */
@media(max-width:700px){
  .menu-footer,.footer{flex-wrap:wrap!important}
  .quick-links{justify-content:flex-start!important}
}

/* Accessibilité tactile */
@media (pointer:coarse){
  button,.btn,a.btn,.nav-link,.mgmt-mini,.mgmt-icon-btn,.toolbtn{min-height:44px}
  input[type="checkbox"],input[type="radio"]{min-width:20px;min-height:20px}
}

/* Hauteur mobile réelle : évite que les barres du navigateur masquent les actions */
@supports (height:100dvh){
  .menu-page,.page{min-height:100dvh!important}
  .object-drawer,.management-drawer{height:100dvh!important}
  .context-modal iframe{height:72dvh!important}
}
.management-drawer{max-width:100vw!important}
@media(max-width:760px){
  .management-drawer{width:100vw!important}
  .drawer-foot{flex-wrap:wrap!important}
  .drawer-foot>*{flex:1 1 150px}
}

/* Tables anciennes : conserver l'accès à toutes les colonnes sans casser le layout */
@media(max-width:768px){
  .em-responsive-table-scroll{max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain;-webkit-overflow-scrolling:touch;scrollbar-width:thin}
  .em-responsive-table-scroll > table{width:max-content;min-width:100%}
}

/* Compléments responsive 04/11/2026 — écrans tactiles et petits formats */
:root{--em-mobile-safe-bottom:env(safe-area-inset-bottom,0px)}
body{min-width:0;overscroll-behavior-x:none}
main,section,article,.card,.card-body,.panel,.panel-body,.modal-content,.tab-content{min-width:0}
:where(button,a,[role="button"],input,select,textarea):not(#map *):not(.gm-style *){touch-action:manipulation}
:where(input,textarea,select){font-size:max(16px,1em)}
:where(button,a,input,select,textarea):focus-visible{outline:3px solid #e3ae00;outline-offset:2px}
:where(.tablewrap,.table-wrap,.tablewraper,.table-container,.table-responsive,.table-scroll,.em-responsive-table-scroll){max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
:where(.tablewrap,.table-wrap,.table-responsive) table{min-width:max-content}
:where(.tabs,.nav-tabs,.mgmt-tabs,.op-stepper,.toolbar){scrollbar-width:thin;overscroll-behavior-x:contain}
:where(.tabs,.nav-tabs,.mgmt-tabs) > :where(.active,[aria-selected="true"]){scroll-margin-inline:20px}
:where(.modal-dialog,.dialog,.popup,.popover,.dropdown-menu){max-width:calc(100vw - 12px)}
@media(max-width:900px){
 .modal-dialog{width:calc(100vw - 16px);margin:8px auto}
 .modal-content{max-height:calc(100dvh - 16px);overflow:hidden}
 .modal-body{overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
 :where(.tabs,.nav-tabs,.mgmt-tabs,.toolbar){max-width:100%;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}
 .map-management{min-width:0!important}
 .map-management .mgmt-detail{display:block!important}
 .em-shortcuts{max-width:calc(100vw - 16px)}
}
@media(max-width:600px){
 :where(.btn,button,[role="button"]){max-width:100%;min-height:42px}
 :where(.modal-header,.modal-footer,.dialog-actions){gap:8px;flex-wrap:wrap}
 .modal-footer > :where(button,.btn){flex:1 1 140px}
 :where(.card-header,.panel-header,.filters,.form-grid){min-width:0}
 .op-cards,.op-types,.operation-cards{grid-template-columns:minmax(0,1fr)!important}
 .op-stepper,.op-stepper-five{display:flex!important;overflow-x:auto!important;white-space:nowrap!important;gap:6px!important}
 .op-stepper > *,.op-stepper-five > *{flex:0 0 auto;min-width:120px}
 .map-legend,.analysis-legend{max-width:calc(100vw - 24px)!important;overflow-y:auto}
 .pa-modal,.pa-dialog,.property-modal{max-width:calc(100vw - 12px)!important;max-height:calc(100dvh - 12px)!important}
 .em-shortcuts-home,.em-shortcuts-primary,.em-shortcuts-details summary{min-height:44px;display:inline-flex;align-items:center}
}
@media(max-height:500px) and (orientation:landscape){
 .modal-dialog,.modal-content{max-height:calc(100dvh - 8px)!important}
 .modal-body{max-height:calc(100dvh - 110px);overflow-y:auto}
}
@media print{
 .em-responsive-table-scroll{overflow:visible!important;max-width:none!important}
 .em-shortcuts,.em-mobile-only{display:none!important}
}

/* v15 — écrans tactiles : zones de toucher confortables (≥ 36–44 px) sans modifier la mise en page bureau. */
@media (pointer:coarse){
  .form-check-input{width:1.4rem;height:1.4rem}
  input[type=checkbox],input[type=radio]{min-width:22px;min-height:22px}
  .panel-close,.select2-selection__clear,.btn-close{min-width:40px;min-height:40px}
  a.small,.dgid-footer a,footer a,.developer-account-back{display:inline-flex;align-items:center;min-height:36px}
  .select2-container .select2-selection--single,.select2-container .select2-selection--multiple{min-height:44px}
  .dropdown-item,.em-shortcuts-menu a{min-height:44px;display:flex;align-items:center}
}

/* === Fenêtres modales : défilement garanti sur petit écran (v2.3) === */
.modal-dialog { max-width: min(var(--bs-modal-width, 500px), calc(100vw - 1rem)); }
.modal-dialog-scrollable .modal-content > form {
  display: flex; flex-direction: column; min-height: 0; max-height: 100%; overflow: hidden;
}
.modal-dialog-scrollable .modal-content > form > .modal-body { overflow-y: auto; min-height: 0; }
.modal-dialog-scrollable .modal-content > form > .modal-header,
.modal-dialog-scrollable .modal-content > form > .modal-footer { flex-shrink: 0; }
.modal-body { overflow-wrap: anywhere; }
.modal-body .table-responsive, .modal-body .adm-table-wrap { max-width: 100%; overflow-x: auto; }
.select2-container--open .select2-dropdown .select2-results__options { max-height: min(260px, 40vh); overflow-y: auto; }
