/* GX Tracking | Fleet bottom dock sizing fix (candidate, NOT deployed).
 * Scoped to the mobile fleet view. Only History, Fences and Share should
 * occupy the three slots. The Detail action remains available in device view.
 * No changes to labels, handlers, appearance or desktop.
 */
@media (max-width: 850px) {
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav[data-gx64-view="fleet"] #gx64Actions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav[data-gx64-view="fleet"] #gx64Actions > button[data-gx64-action="detail"] {
    display: none !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav[data-gx64-view="fleet"] #gx64Actions > button[data-gx64-action="history"] {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav[data-gx64-view="fleet"] #gx64Actions > button[data-gx64-action="fence"] {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav[data-gx64-view="fleet"] #gx64Actions > button[data-gx64-action="share"] {
    grid-column: 3 !important;
    grid-row: 1 !important;
  }
}

/* GX v0.10.76 moves the SAME #gx64Back into #gx64Actions; v0.10.96
 * subsequently moves #gx64Actions out of #sidebar and into <body>.
 * Therefore v0.10.76's #sidebar #gx64Actions grid never matches the
 * final DOM. Keep the native Back click handler and show ALL actions in
 * exactly one row; no JavaScript/handlers or content panels are changed.
 */
@media (max-width: 850px) {
  /* Non-fleet, no device: Back + History + Fences + Share = 4 columns.
   * Examples: global geofence view or pending-device flow.
   */
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions:not([data-gx64-view="fleet"]):not(.gx64-selected) #gx64Actions {
    grid-template-columns: 36px repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }
  /* Non-fleet, selected device: Back + Details + History + Fences + Share. */
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions {
    grid-template-columns: 36px repeat(4, minmax(0, 1fr)) !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }
  /* Back was reparented by the existing mobile shell. Preserve the one
   * original button/listener rather than cloning or changing navigation.
   */
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions:not([data-gx64-view="fleet"]) #gx64Actions > #gx64Back {
    display: flex !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
  }
  /* Any fleet state must show ONLY the established three actions. */
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions[data-gx64-view="fleet"] #gx64Actions > #gx64Back,
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions[data-gx64-view="fleet"] #gx64Actions > button[data-gx64-action="detail"] {
    display: none !important;
  }
  /* Non-fleet without device: Details is not actionable. */
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions:not([data-gx64-view="fleet"]):not(.gx64-selected) #gx64Actions > button[data-gx64-action="detail"] {
    display: none !important;
  }
  /* Back + 3 or Back + 4: explicitly anchor each action in row 1.
   * Existing v0.10.96 handles colors, icon size, height and safe area.
   */
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions:not([data-gx64-view="fleet"]):not(.gx64-selected) #gx64Actions > button[data-gx64-action="history"] {
    grid-column: 2 !important; grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions:not([data-gx64-view="fleet"]):not(.gx64-selected) #gx64Actions > button[data-gx64-action="fence"] {
    grid-column: 3 !important; grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions:not([data-gx64-view="fleet"]):not(.gx64-selected) #gx64Actions > button[data-gx64-action="share"] {
    grid-column: 4 !important; grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions > button[data-gx64-action="detail"] {
    display: flex !important; grid-column: 2 !important; grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions > button[data-gx64-action="history"] {
    grid-column: 3 !important; grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions > button[data-gx64-action="fence"] {
    grid-column: 4 !important; grid-row: 1 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions > button[data-gx64-action="share"] {
    grid-column: 5 !important; grid-row: 1 !important;
  }
}
/* Only at very narrow widths, restore the original v0.10.76 compact
 * sizing that stopped matching when v0.10.96 reparented the bar.
 */
@media (max-width: 360px) {
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions {
    grid-template-columns: 32px repeat(4, minmax(0, 1fr)) !important;
    gap: 3px !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions > button {
    font-size: clamp(8px, 2.58vw, 9px) !important;
    letter-spacing: -.025em !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  html body.tracking-dashboard.gx64-mobile.gx96-fixed-nav.gx76-compact-actions.gx64-selected:not([data-gx64-view="fleet"]) #gx64Actions > button svg {
    width: 11px !important;
    height: 11px !important;
  }
}
