/* ============================================================================
   PAGE V01 / FOOTER 01 — DEV 1.2.14
   FOOTER 01 est indépendant de MEP MOD 01, actif par défaut.
   body.no-footer le désactive ponctuellement.
   ============================================================================ */
@media (orientation:landscape) and (min-width:900px) {
  body.device-tablet { --tt-page-footer-height:var(--tt-tablet-footer-height); }

  /* DEV 1.2.18 : aucune bande vide entre MEP MOD 01 et FOOTER 01.
     BG/BD touchent la frontière FOOTER 01. */

  body.device-tablet .ttModuleFrame {
    bottom:calc(var(--tt-page-footer-height) + 4px) !important;
  }

  /* DEV 1.2.67 — marge basse définitive entre les zones BG/BD et le cadre principal.
     On rétablit le même padding que sur les autres côtés du cadre : 6 px via
     --tt-tablet-frame-padding. Le FOOTER 01 reste à sa position actuelle. */
  body.device-tablet .ttModuleFrame {
    padding-bottom:var(--tt-tablet-frame-padding) !important;
  }

  /* La ligne verticale MEP doit elle aussi rejoindre FOOTER 01. */
  body.device-tablet .ttModuleFrame::before {
    bottom:0 !important;
  }

  body.device-tablet > .kalaFooter {
    position:fixed !important;
    left:var(--tt-tablet-edge) !important;
    right:var(--tt-tablet-edge) !important;
    bottom:2px !important;
    width:auto !important;
    height:var(--tt-page-footer-height) !important;
    min-height:var(--tt-page-footer-height) !important;
    margin:0 !important;
    padding:0 4px !important;
    font-size:10px !important;
    line-height:1 !important;
    z-index:10000 !important;
    overflow:visible !important;
  }

  /* 3e ligne jaune : frontière MEP MOD 01 / FOOTER 01 */
  body.device-tablet > .kalaFooter::before {
    content:"";
    position:absolute;
    left:0; right:0; top:-2px;
    height:var(--tt-layout-debug-width,1px);
    background:var(--tt-layout-debug-color,#ffd400);
    opacity:var(--tt-layout-debug-opacity,1);
    pointer-events:none;
  }

  body.device-tablet.no-footer > .kalaFooter { display:none !important; }
  body.device-tablet.no-footer .ttModuleFrame { bottom:var(--tt-tablet-edge) !important; }
  body.device-tablet.module-selection > .kalaFooter { display:none !important; }
  body.device-tablet.module-selection .moduleKalaFooter { display:grid !important; }
}


/* H11: ancienne autorité tablette H10 retirée. La zone HD tablette est désormais pilotée uniquement par CSS_40_Tablette_ZoneHD_Final, chargé EN DERNIER. */

/* ---------- TÉLÉPHONE ---------- */
@media (max-width:700px){
  body.device-phone{
    --tt-ph-h:36px;
    --tt-ph-module-w:82px;
    --tt-ph-fs-w:36px;
    --tt-ph-status-w:116px; /* largeur validée visuellement en Gestion/Admin */
    --tt-ph-gap:4px;
  }

  body.device-phone #app.ttModuleFrame > .ttZoneHD > #controlCard.ttZone0,
  body.device-phone .hostessFrame.ttModuleFrame > .ttZoneHD > .hostessControlCard.ttZone0,
  body.device-phone .statisticsShell.ttModuleFrame > .ttZoneHD > .statisticsCommandRow.ttZone0,
  body.device-phone .workspaceFrame.ttModuleFrame > .ttZoneHD > .workspaceControlCard.ttZone0{
    box-sizing:border-box!important;width:100%!important;min-width:0!important;height:48px!important;min-height:48px!important;max-height:48px!important;
    padding:6px!important;margin:0!important;overflow:hidden!important;
  }

  body.device-phone #app.ttModuleFrame .ttZone0Actions,
  body.device-phone .hostessFrame.ttModuleFrame .ttZone0Actions,
  body.device-phone .statisticsShell.ttModuleFrame .ttZone0Actions,
  body.device-phone .workspaceFrame.ttModuleFrame .ttZone0Actions{
    box-sizing:border-box!important;display:grid!important;width:100%!important;min-width:0!important;
    height:var(--tt-ph-h)!important;min-height:var(--tt-ph-h)!important;max-height:var(--tt-ph-h)!important;
    margin:0!important;padding:0!important;column-gap:var(--tt-ph-gap)!important;row-gap:0!important;
    align-items:stretch!important;justify-items:stretch!important;
  }

  body.device-phone #app.ttModuleFrame #moduleBtn,
  body.device-phone .hostessFrame.ttModuleFrame #hostessModuleBtn,
  body.device-phone .workspaceFrame.ttModuleFrame .workspaceControlBtn.ttZone0AnchorLeft,
  body.device-phone .statisticsShell.ttModuleFrame #statisticsBackBtn,
  body.device-phone .ttModuleFrame .ttZoneHD .ttQuickFullscreenBtn,
  body.device-phone #app.ttModuleFrame #simulationControl,
  body.device-phone .statisticsShell.ttModuleFrame #statisticsRefreshBtn,
  body.device-phone .ttModuleFrame .ttZoneHD .ttStatusClusterHost{
    box-sizing:border-box!important;height:var(--tt-ph-h)!important;min-height:var(--tt-ph-h)!important;max-height:var(--tt-ph-h)!important;
    margin:0!important;top:auto!important;bottom:auto!important;transform:none!important;align-self:stretch!important;
  }

  body.device-phone #app.ttModuleFrame #moduleBtn,
  body.device-phone .hostessFrame.ttModuleFrame #hostessModuleBtn,
  body.device-phone .workspaceFrame.ttModuleFrame .workspaceControlBtn.ttZone0AnchorLeft,
  body.device-phone .statisticsShell.ttModuleFrame #statisticsBackBtn{
    width:var(--tt-ph-module-w)!important;min-width:var(--tt-ph-module-w)!important;max-width:var(--tt-ph-module-w)!important;
    padding:0 5px!important;font-size:9.5px!important;
  }

  body.device-phone .ttModuleFrame .ttZoneHD .ttQuickFullscreenBtn{
    width:var(--tt-ph-fs-w)!important;min-width:var(--tt-ph-fs-w)!important;max-width:var(--tt-ph-fs-w)!important;
    padding:0!important;border-radius:9px!important;display:flex!important;align-items:center!important;justify-content:center!important;
  }

  body.device-phone .ttModuleFrame .ttZoneHD .ttStatusClusterHost{
    width:var(--tt-ph-status-w)!important;min-width:var(--tt-ph-status-w)!important;max-width:var(--tt-ph-status-w)!important;
    display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:1px!important;padding:2px!important;margin-left:auto!important;justify-self:end!important;
  }
  body.device-phone .ttModuleFrame .ttZoneHD .ttStatusClusterHost .ttStatusPill{
    min-width:0!important;width:100%!important;height:100%!important;margin:0!important;padding:0!important;
    display:flex!important;align-items:center!important;justify-content:center!important;
  }
  body.device-phone .ttModuleFrame .ttZoneHD .ttStatusClusterHost .ttStatusIcon{
    width:18px!important;height:18px!important;flex:0 0 18px!important;
  }

  /* Caisse : compacte MODULES, laisse toute la place utile à SIMULATION, états à droite */
  body.device-phone #app.ttModuleFrame > .ttZoneHD > #controlCard.ttZone0 > .controlGrid.ttZone0Actions{
    grid-template-columns:var(--tt-ph-module-w) var(--tt-ph-fs-w) minmax(90px,1fr) var(--tt-ph-status-w)!important;
  }
  body.device-phone #app.ttModuleFrame #moduleBtn{grid-column:1!important;}
  body.device-phone #app.ttModuleFrame #caisseQuickFullscreenBtn{grid-column:2!important;}
  body.device-phone #app.ttModuleFrame #simulationControl{grid-column:3!important;min-width:0!important;width:100%!important;padding-left:4px!important;padding-right:4px!important;font-size:9px!important;white-space:nowrap!important;overflow:hidden!important;}
  body.device-phone #app.ttModuleFrame #syncBadge{grid-column:4!important;justify-self:end!important;}

  /* Hôtesse, Gestion, Administration : le groupe états est toujours tout à droite */
  body.device-phone .hostessFrame.ttModuleFrame > .ttZoneHD > .hostessControlCard.ttZone0 > .hostessControlGrid.ttZone0Actions,
  body.device-phone .workspaceFrame.ttModuleFrame > .ttZoneHD > .workspaceControlCard.ttZone0 > .workspaceControlRow.ttZone0Actions{
    grid-template-columns:var(--tt-ph-module-w) var(--tt-ph-fs-w) minmax(0,1fr) var(--tt-ph-status-w)!important;
  }
  body.device-phone .hostessFrame.ttModuleFrame #hostessModuleBtn,
  body.device-phone .workspaceFrame.ttModuleFrame .workspaceControlBtn.ttZone0AnchorLeft{grid-column:1!important;}
  body.device-phone .hostessFrame.ttModuleFrame #hostessQuickFullscreenBtn,
  body.device-phone .workspaceFrame.ttModuleFrame .ttQuickFullscreenBtn{grid-column:2!important;}
  body.device-phone .hostessFrame.ttModuleFrame #hostessSyncBadge,
  body.device-phone .workspaceFrame.ttModuleFrame .workspaceSyncBadge{grid-column:4!important;justify-self:end!important;margin-left:auto!important;}

  /* Statistiques : MODULES et REFRESH = même largeur, compactes et lisibles */
  body.device-phone .statisticsShell.ttModuleFrame > .ttZoneHD > .statisticsCommandRow.ttZone0 > .statisticsUnifiedActions.ttZone0Actions{
    grid-template-columns:var(--tt-ph-module-w) var(--tt-ph-fs-w) var(--tt-ph-module-w) minmax(0,1fr) var(--tt-ph-status-w)!important;
  }
  body.device-phone .statisticsShell.ttModuleFrame #statisticsBackBtn{grid-column:1!important;}
  body.device-phone .statisticsShell.ttModuleFrame #statisticsQuickFullscreenBtn{grid-column:2!important;}
  body.device-phone .statisticsShell.ttModuleFrame #statisticsRefreshBtn{display:flex!important;grid-column:3!important;width:var(--tt-ph-module-w)!important;min-width:var(--tt-ph-module-w)!important;max-width:var(--tt-ph-module-w)!important;padding:0 4px!important;font-size:9px!important;}
  body.device-phone .statisticsShell.ttModuleFrame #statisticsSyncBadge{grid-column:5!important;justify-self:end!important;margin-left:auto!important;}
  body.device-phone .statisticsShell.ttModuleFrame #statisticsGeneralBtn,
  body.device-phone .statisticsShell.ttModuleFrame #statisticsDetailBtn,
  body.device-phone .statisticsShell.ttModuleFrame #statisticsViewSelect{display:none!important;}
}

/* DEV 1.2.155H17 — interrupteur de boucle autonome DEV dans le footer. */
.ttDevLoopToggle{display:none;align-items:center;gap:4px;margin-left:5px;font-size:8px;font-weight:900;white-space:nowrap;user-select:none;}
body[data-environment="DEV"].authenticated.dev-loop-authorized .ttDevLoopToggle{display:inline-flex;}
.ttDevLoopToggle input{width:13px;height:13px;margin:0;accent-color:#17a673;}
.ttDevLoopToggle.active span{color:#4ed89a;}
.ttDevLoopToggle.pending span{color:#f2b84b;}
body[data-environment="PROD"] .ttDevLoopToggle{display:none !important;}


/* DEV 1.3.1B — IGOR disponible aussi dans le footer MODULES/mobile. */
.ttDevLoopToggleModule{margin-left:4px;}
@media (max-width:700px){
  body.device-phone.module-selection .moduleKalaFooter .kalaCenterTools{min-width:0;gap:4px;}
  body.device-phone.module-selection .moduleKalaFooter .ttDevLoopToggleModule{margin-left:1px;font-size:8px;flex:0 0 auto;}
  body.device-phone.module-selection .moduleKalaFooter .ttDevLoopToggleModule input{width:13px;height:13px;}
}

/* J20I — sécurité structurelle : aucun contrôle Igor statique hors session admin. */
body:not(.authenticated) .ttDevLoopToggle,body:not(.dev-loop-authorized) .ttDevLoopToggle{display:none!important;visibility:hidden!important;}


/* DEV 1.3.3G — mini barre d'outils SUPER_ADMIN dans le footer. */
.ttAdminToolBtn{
  display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;
  height:18px;min-height:18px;min-width:30px;padding:0 5px;margin:0 1px;
  border:1px solid rgba(80,105,125,.55);border-radius:5px;
  background:rgba(240,246,250,.92);color:#173d50;
  font:900 8px/1 Arial,sans-serif;cursor:pointer;white-space:nowrap;
}
.ttAdminToolBtn.active{box-shadow:inset 0 0 0 1px rgba(39,184,117,.55);color:#087a46;}
body[data-theme="dark"] .ttAdminToolBtn{background:rgba(26,42,54,.96);border-color:rgba(126,166,190,.60);color:#e8f7ff;}
body[data-theme="dark"] .ttAdminToolBtn.active{color:#58e7a4;}
body:not(.authenticated) .ttAdminToolBtn{display:none!important;}
