/* Reforger Manager 3.7.2 — fluid desktop shell and readable navigation.
   Layout-only overrides: no billing, permissions or module business logic. */

/* Scope the wide layout to an open server dashboard; login/server selection
   keep their previous, readable page width. */
main:has(#admin-panel) {
  width: min(96vw, 3200px);
  max-width: none;
  margin-inline: auto;
  padding: clamp(18px, 1.2vw, 34px) 0 60px;
}
main:has(#admin-panel) #dashboard,
main:has(#admin-panel) #admin-panel {
  width: 100%;
  max-width: none;
  min-width: 0;
}

@media (min-width: 881px) {
  :root { --rfm-wide-sidebar: clamp(292px, 19vw, 352px); }

  .rfm-admin-shell {
    grid-template-columns: var(--rfm-wide-sidebar) minmax(0, 1fr);
    gap: clamp(18px, 1.3vw, 28px);
    align-items: start;
  }
  .rfm-admin-header {
    grid-template-columns: var(--rfm-wide-sidebar) minmax(0, 1fr) auto;
    gap: clamp(18px, 1.3vw, 28px);
  }
  .rfm-sidebar {
    min-width: 0;
    padding: 14px;
  }
  .rfm-sidebar-navigation {
    min-width: 0;
    padding-inline: 1px 5px;
  }
  .rfm-sidebar-navigation .rfm-tier-sidebar-items .admin-menu-item {
    min-width: 0;
    gap: 10px;
    padding: 9px 10px;
    font-size: 12.5px;
  }
  .rfm-sidebar-navigation .rfm-tier-sidebar-items .admin-menu-item > span:nth-child(2) {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Only if a very long localization exceeds sidebar */
  }
  .rfm-sidebar-navigation .rfm-nav-tier {
    flex: 0 0 auto;
    font-size: 9px;
    padding: 4px 6px;
  }
  .rfm-sidebar-navigation .rfm-tier-sidebar-group > summary {
    padding: 12px 12px;
    font-size: 10.5px;
  }
  .rfm-sidebar .rfm-server-card-name { font-size: 14px; }
  .rfm-content { min-width: 0; padding-inline: 0; }

  /* Wide content grids should scale with the canvas, not stay at 1140px. */
  .rfm-home-dashboard,
  .rfm-billing-page,
  .community-page {
    width: 100%;
    max-width: none;
    margin-inline: 0;
  }
  .rfm-billing-page { padding: 22px 0 54px; }
  .community-page { padding-inline: 0; }
  .rfm-billing-feature-table { min-width: 720px; }
  .rfm-module-center { min-width: 0; }
  .rfm-module-card { min-width: 0; }
  .rfm-module-main { min-width: 0; }
  .rfm-module-top { flex-wrap: wrap; }
  .rfm-page-hero { padding: 27px 32px; }
}

/* On very wide displays, use the extra room for more module cards rather
   than making each card excessively long. */
@media (min-width: 1900px) {
  .rfm-module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rfm-billing-comparison-cards { gap: 18px; }
  .rfm-billing-comparison-card { padding: 22px; }
}
@media (min-width: 2900px) {
  .rfm-module-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Mid-size viewports: preserve room for cards and inputs. The primary sidebar
   stays readable, then stacks before the content becomes cramped. */
@media (min-width: 881px) and (max-width: 1199px) {
  :root { --rfm-wide-sidebar: 274px; }
  .rfm-admin-header { grid-template-columns: minmax(0, 1fr) auto; }
  .rfm-global-search { display: none; }
  .rfm-user-meta { display: none; }
  .rfm-sidebar-navigation .rfm-tier-sidebar-items .admin-menu-item { font-size: 12px; gap: 7px; padding-inline: 7px; }
}
@media (max-width: 880px) {
  main:has(#admin-panel) { width: min(96vw, 760px); padding: 16px 0 40px; }
  .rfm-admin-shell { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .rfm-admin-header { grid-template-columns: minmax(0, 1fr) auto; }
  .rfm-global-search { display: none; }
  .rfm-user-meta { display: none; }
  .rfm-sidebar {
    display: flex;
    position: relative;
    top: auto;
    min-height: 0;
    height: auto;
    max-height: min(64dvh, 510px);
    padding: 12px;
  }
  .rfm-sidebar-navigation { min-height: 0; flex: 1 1 auto; max-height: min(39dvh, 320px); }
  .rfm-sidebar .rfm-server-card { grid-column: auto; }
  .rfm-sidebar .rfm-bot-card, .rfm-sidebar .rfm-support-button { display: none; }
  .rfm-content { min-width: 0; padding-inline: 0; }
  .rfm-home-dashboard, .rfm-billing-page, .community-page { width:100%; max-width:none; margin-inline:0; }
  .rfm-billing-page { padding: 16px 0 40px; }
  .community-page { padding-inline:0; }
}
@media (max-width: 600px) {
  main:has(#admin-panel) { width: 95vw; }
  .rfm-admin-header { gap: 10px; }
  .rfm-sidebar { max-height: 55dvh; }
  .rfm-sidebar-navigation { max-height: 31dvh; }
  .rfm-page-hero { padding: 19px; }
  .rfm-home-status-grid { grid-template-columns: minmax(0,1fr); }
  .rfm-billing-feature-table { min-width: 720px; } /* contained by horizontal scroll wrapper */
}

/* Spunta con nota a destra: la spunta resta sempre sull'asse centrale della colonna (slot fisso),
   la nota occupa lo slot a destra senza spostare la spunta. */
.rfm-billing-feature-table td .rfm-ad-cell {
  display: grid;
  grid-template-columns: minmax(0,1fr) 18px minmax(0,1fr);
  align-items: center;
  width: 100%;
  min-width: 0;
}
.rfm-billing-feature-table td .rfm-ad-cell[data-rfm-tip] { cursor: help; }
.rfm-billing-feature-table td .rfm-ad-cell[data-rfm-tip]:focus-visible { outline: 2px solid #8f7cf0; outline-offset: 2px; border-radius: 6px; }
.rfm-billing-feature-table td .rfm-ad-check {
  grid-column: 2;
  text-align: center;
  font-weight: 700;
}
.rfm-billing-feature-table td .rfm-ad-label {
  grid-column: 3;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
  margin-left: 8px;
  font-size: 10px;
  color: #aebcd4;
}
.rfm-compare-tip {
  position: fixed;
  z-index: 2147483000;
  max-width: min(260px, calc(100vw - 16px));
  padding: 6px 10px;
  border: 1px solid #35415a;
  border-radius: 8px;
  background: #18233a;
  color: #dce5f8;
  font-size: 11px;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  pointer-events: none;
}

/* Desktop sidebar: viewport anchoring without the sticky container end-stop.
   The grid column is retained; mobile keeps its normal document flow. */
@media (min-width: 881px) {
  #admin-panel .rfm-admin-shell.rfm-viewport-sidebar {
    min-height: var(--rfm-nav-space);
  }
  #admin-panel .rfm-viewport-sidebar > .rfm-sidebar {
    position: fixed;
    left: var(--rfm-nav-left);
    top: var(--rfm-nav-top);
    width: var(--rfm-nav-width);
    height: var(--rfm-nav-height);
    min-height: 0;
    max-height: none;
    box-sizing: border-box;
    z-index: 20;
  }
  #admin-panel .rfm-viewport-sidebar > .rfm-content {
    grid-column: 2;
    grid-row: 1;
  }
}
