/* RCH v1.7-STAB2-P1-B — Territory refresh visual stabilization.
   The refresh action is layered by legacy/header/UX rules. This final owner
   keeps its geometry deterministic and animates only the Lucide glyph while
   refreshTerritoryData() owns .is-loading / aria-busy. */

body.rch-territory-v1 .rch-home-header #refreshBtn {
  position:relative !important;
  isolation:isolate;
  box-sizing:border-box !important;
  align-items:center !important;
  justify-content:center !important;
  vertical-align:middle;
}

body.rch-territory-v1 .rch-home-header #refreshBtn::before,
body.rch-territory-v1 .rch-home-header #refreshBtn::after {
  content:none !important;
  display:none !important;
}

body.rch-territory-v1 .rch-home-header #refreshBtn > :is(i[data-lucide="refresh-cw"],svg) {
  display:block !important;
  width:1.08rem !important;
  height:1.08rem !important;
  min-width:1.08rem !important;
  min-height:1.08rem !important;
  margin:0 !important;
  padding:0 !important;
  flex:0 0 1.08rem !important;
  transform-origin:50% 50% !important;
  transform-box:fill-box;
  pointer-events:none;
}

/* P0 collapses the label up to 100rem. In that icon-only range the refresh
   action must be a true square, not the historical 2.55rem x compact-height
   rectangle produced by competing layers. */
@media (min-width:72.01rem) and (max-width:100rem) {
  body.rch-territory-v1 .rch-home-header #refreshBtn {
    display:inline-grid !important;
    place-items:center !important;
    width:var(--rch-control-compact) !important;
    min-width:var(--rch-control-compact) !important;
    max-width:var(--rch-control-compact) !important;
    height:var(--rch-control-compact) !important;
    min-height:var(--rch-control-compact) !important;
    max-height:var(--rch-control-compact) !important;
    padding:0 !important;
    flex:0 0 var(--rch-control-compact) !important;
  }
}

@media (max-width:72rem) {
  body.rch-territory-v1 .rch-home-header #refreshBtn {
    display:inline-grid !important;
    place-items:center !important;
    width:var(--rch-control-comfort) !important;
    min-width:var(--rch-control-comfort) !important;
    max-width:var(--rch-control-comfort) !important;
    height:var(--rch-control-comfort) !important;
    min-height:var(--rch-control-comfort) !important;
    max-height:var(--rch-control-comfort) !important;
    padding:0 !important;
    flex:0 0 var(--rch-control-comfort) !important;
  }
}

/* Loading must not deform or fade the command. The existing JS sets disabled,
   aria-busy and .is-loading around the actual refresh operation. */
body.rch-territory-v1 .rch-home-header #refreshBtn.is-loading,
body.rch-territory-v1 .rch-home-header #refreshBtn[aria-busy="true"] {
  opacity:1 !important;
  cursor:progress !important;
  color:#17365f !important;
  background:rgba(255,255,255,.96) !important;
  border-color:rgba(188,207,229,.9) !important;
}

body.rch-territory-v1 .rch-home-header #refreshBtn.is-loading > svg,
body.rch-territory-v1 .rch-home-header #refreshBtn[aria-busy="true"] > svg {
  animation:rch-p1b-territory-refresh-spin .72s linear infinite;
  will-change:transform;
}

@keyframes rch-p1b-territory-refresh-spin {
  to { transform:rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  body.rch-territory-v1 .rch-home-header #refreshBtn.is-loading > svg,
  body.rch-territory-v1 .rch-home-header #refreshBtn[aria-busy="true"] > svg {
    animation:none !important;
    will-change:auto;
  }
}
