/**
 * Coque mobile GCE IR Studio — téléphone uniquement.
 * Toutes les règles sont gated body.ir-mobile-simple (PC inchangé).
 */

#ir-mobile-chrome {
  display: none !important;
}

body.ir-mobile-simple #ir-mobile-chrome {
  display: block !important;
}

body.ir-mobile-simple #ir-mobile-chrome[hidden] {
  display: none !important;
}

/* Masquer le chrome dense PC / compact — le canvas reste. */
body.ir-mobile-simple .toolbar,
body.ir-mobile-simple .gce-ir-appmenu,
body.ir-mobile-simple .ir-detached-panel.ir-constructor-dock,
body.ir-mobile-simple #ir-memory-bottom-panel,
body.ir-mobile-simple .gce-ir-topbar-nav .gce-ir-topbar-link--shop,
body.ir-mobile-simple .gce-ir-topbar-nav .gce-ir-topbar-link--admin,
body.ir-mobile-simple .gce-ir-topbar-nav .gce-ir-topbar-link--demo {
  display: none !important;
}

body.ir-mobile-simple .sidebar {
  /* Drawer complet encore dispo via « Menu complet », mais hors flux par défaut. */
  z-index: 10045;
}

body.ir-mobile-simple .editor-shell,
body.ir-mobile-simple .main-layout,
body.ir-mobile-simple .workspace {
  width: 100% !important;
  max-width: 100vw !important;
  left: 0 !important;
}

body.ir-mobile-simple .workspace {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

/* Why: le MQ compact pose top:10px ; si on ajoute bottom sans reset → barre étirée sur toute la hauteur. */
body.ir-mobile-simple #help-bar {
  top: 8px !important;
  left: 8px !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  width: auto !important;
  max-width: min(56vw, 11rem) !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 4px 10px !important;
  font-size: 0.65rem !important;
  line-height: 1.25 !important;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px !important;
  pointer-events: none;
  z-index: 480;
}

body.ir-mobile-simple #ir-selection-bar {
  bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Why: le navigateur ne doit pas voler pinch/pan — 1 doigt = objet, 2 doigts = vue. */
body.ir-mobile-simple .workspace,
body.ir-mobile-simple .canvas-wrapper,
body.ir-mobile-simple .canvas-wrapper canvas {
  touch-action: none;
  -ms-touch-action: none;
}

body.ir-mobile-simple .ir-3d-preview:not(.ir-3d-fullscreen) {
  /* Éviter la bande 3D qui écrase la planche — CTA via onglet Éditer. */
  max-height: 28vh;
}

/* —— Tab bar —— */
.ir-mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10060;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
  min-height: 58px;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  background: #0a0a0e;
  border-top: 1px solid rgba(0, 210, 190, 0.35);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
}

.ir-mobile-tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 6px 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #ffffff88;
  font-family: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ir-mobile-tab i {
  font-size: 1.05rem;
  line-height: 1;
}

.ir-mobile-tab.is-active,
.ir-mobile-tab[aria-pressed="true"] {
  color: #00d2be;
  background: rgba(0, 210, 190, 0.12);
}

/* —— Sheet —— */
.ir-mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 10070;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.ir-mobile-sheet[hidden] {
  display: none !important;
}

.ir-mobile-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.ir-mobile-sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(72dvh, 560px);
  display: flex;
  flex-direction: column;
  background: #101016;
  border-radius: 16px 16px 0 0;
  border: 1px solid rgba(0, 210, 190, 0.28);
  border-bottom: 0;
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.5);
  padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  animation: irMobileSheetUp 0.28s ease;
}

@keyframes irMobileSheetUp {
  from { transform: translateY(18%); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.ir-mobile-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.ir-mobile-sheet-title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #00d2be;
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  font-weight: 700;
}

.ir-mobile-sheet-close {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #18181f;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.ir-mobile-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 16px;
  touch-action: pan-y;
}

.ir-mobile-sheet-host .section-body,
.ir-mobile-sheet-host .section-body.closed {
  display: block !important;
  max-height: none !important;
  overflow: visible !important;
  padding: 0 !important;
  border: 0 !important;
}

.ir-mobile-sheet-host #sidebar-order-footer {
  position: static !important;
  margin: 0 !important;
  border: 0 !important;
  padding: 0 !important;
}

/* Tools grid */
.ir-mobile-tools-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}

.ir-mobile-tools-grid[hidden],
.ir-mobile-more-actions[hidden] {
  display: none !important;
}

.ir-mobile-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid rgba(0, 210, 190, 0.28);
  background: #16161c;
  color: #eee;
  font-family: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.ir-mobile-tool i {
  font-size: 1.15rem;
  color: #00d2be;
}

.ir-mobile-tool.is-active {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.18);
}

.ir-mobile-more-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ir-mobile-more-btn {
  width: 100%;
  min-height: 46px;
  justify-content: center;
  gap: 8px;
  background: #1a1a22 !important;
  border: 1px solid rgba(0, 210, 190, 0.4) !important;
  color: #00d2be !important;
}

/* —— FABs plein écran —— */
.ir-mobile-fs-fabs {
  position: fixed;
  right: 10px;
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 10080;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.ir-mobile-fs-fab {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(0, 210, 190, 0.45);
  background: rgba(10, 10, 14, 0.88);
  color: #00d2be;
  font-size: 1.05rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.ir-mobile-fs-fab[hidden] {
  display: none !important;
}

.ir-mobile-fs-fab[aria-pressed="true"] {
  border-color: #8b5cf6;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.22);
}

/* —— Mode plein écran (CSS + Fullscreen API si dispo) —— */
body.ir-mobile-simple.ir-mobile-fs {
  overflow: hidden;
  overscroll-behavior: none;
}

body.ir-mobile-simple.ir-mobile-fs .gce-ir-topbar,
body.ir-mobile-simple.ir-mobile-fs .ir-header,
body.ir-mobile-simple.ir-mobile-fs .top-nav.ir-header,
body.ir-mobile-simple.ir-mobile-fs .ir-mobile-tabbar,
body.ir-mobile-simple.ir-mobile-fs .ir-3d-preview:not(.ir-3d-fullscreen) {
  display: none !important;
}

body.ir-mobile-simple.ir-mobile-fs .editor-shell,
body.ir-mobile-simple.ir-mobile-fs .main-layout,
body.ir-mobile-simple.ir-mobile-fs .workspace {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  height: 100% !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 1000;
}

body.ir-mobile-simple.ir-mobile-fs .workspace {
  padding-bottom: 0 !important;
  padding-top: env(safe-area-inset-top, 0px);
}

body.ir-mobile-simple.ir-mobile-fs #ir-selection-bar {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
}

body.ir-mobile-simple.ir-mobile-fs #help-bar {
  top: calc(8px + env(safe-area-inset-top, 0px)) !important;
  left: 8px !important;
}

body.ir-mobile-simple.ir-mobile-fs .ir-mobile-fs-fabs {
  top: auto;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  right: 12px;
}

body.ir-mobile-simple.ir-mobile-fs .ir-mobile-sheet {
  z-index: 10090;
}
