/*
 * BB101 Stage 3 — Conservative Layout Guards
 * Scope: structural guardrails only for known shared shell/module-list layouts.
 * This deliberately avoids broad selectors like .nav-tabs, .nav-link, .card, .table, .btn.
 */
:root{
  --bb101-layout-gap: 14px;
  --bb101-icon-sm: 32px;
  --bb101-icon-md: 42px;
  --bb101-icon-lg: 56px;
  --bb101-header-pad-x: 18px;
}

/* Page/module title strips: consistent icon/title spacing without touching module internals. */
:where(.page-title-box,.panel-page-heading,.module-title-row,.badger-page-title,.bc-page-title){
  padding-left: var(--bb101-header-pad-x);
  padding-right: var(--bb101-header-pad-x);
}
:where(.page-title-box,.panel-page-heading,.module-title-row,.badger-page-title,.bc-page-title) :where(img,.module-icon,.page-title-icon,.bc-title-icon){
  width: var(--bb101-icon-md);
  height: var(--bb101-icon-md);
  max-width: var(--bb101-icon-md);
  max-height: var(--bb101-icon-md);
  object-fit: contain;
  flex: 0 0 var(--bb101-icon-md);
  margin-right: 12px;
}

/* Topbar action shortcuts: one row, consistent gaps. */
:where(.topbar-actions,.badger-topbar-actions,.nxt-topbar-actions,.bc-topbar-actions){
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
:where(.topbar-actions,.badger-topbar-actions,.nxt-topbar-actions,.bc-topbar-actions) :where(.btn,a,button){
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

/* Dashboard/module manager identity rows: prevent uploaded transparent PNGs from expanding rows. */
:where(.nxt-module-manager-widget,.dashboard-module-manager,.bc-module-manager,.dashboard-health-table,.module-monitor-table) :where(img,.bc-module-identity-icon,.bc-mm-module-icon,.module-icon-img){
  width: var(--bb101-icon-md) !important;
  height: var(--bb101-icon-md) !important;
  max-width: var(--bb101-icon-md) !important;
  max-height: var(--bb101-icon-md) !important;
  object-fit: contain !important;
  flex: 0 0 var(--bb101-icon-md) !important;
}
:where(.nxt-module-manager-widget,.dashboard-module-manager,.bc-module-manager) :where(.module-row,.bc-module-row,.list-group-item,tr){
  min-height: 58px;
}

/* Sidebar module icons are small and stable. */
:where(.vertical-menu,.sidebar,.app-sidebar,.nxt-sidebar) :where(.nxt-sidebar-app-icon,img.bb-module-icon-img,img.nxt-sidebar-dashboard-img){
  width: var(--bb101-icon-sm) !important;
  height: var(--bb101-icon-sm) !important;
  max-width: var(--bb101-icon-sm) !important;
  max-height: var(--bb101-icon-sm) !important;
  object-fit: contain !important;
  flex: 0 0 var(--bb101-icon-sm) !important;
}

/* API Helper layout guards — scoped only to the helper. */
.api-link-helper :where(.module-card,.api-module-card,.endpoint-category-card,.endpoint-card){
  min-width: 0;
}
.api-link-helper :where(.module-card img,.api-module-card img,.endpoint-category-card img,.endpoint-card img,.module-icon,.endpoint-icon){
  width: var(--bb101-icon-md) !important;
  height: var(--bb101-icon-md) !important;
  max-width: var(--bb101-icon-md) !important;
  max-height: var(--bb101-icon-md) !important;
  object-fit: contain !important;
  flex: 0 0 var(--bb101-icon-md) !important;
}
.api-link-helper :where(.endpoint-grid,.endpoint-cards,.api-endpoint-grid){
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--bb101-layout-gap);
}
.api-link-helper :where(input,textarea){
  min-width: 0;
}

/* Table wrappers: allow horizontal scroll without changing table internals. */
:where(.table-responsive,.dataTables_wrapper,.module-table-wrap,.bc-table-wrap){
  max-width: 100%;
  overflow-x: auto;
}

/* Media preview guardrails used by Smarters Pro and future Builder media widgets. */
:where(.media-preview,.smarters-media-preview,.badger-media-preview,.bc-media-preview){
  max-width: 100%;
  overflow: hidden;
}
:where(.media-preview,.smarters-media-preview,.badger-media-preview,.bc-media-preview) :where(img,video){
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Mobile: keep action rows usable without changing module content layout. */
@media (max-width: 768px){
  :where(.topbar-actions,.badger-topbar-actions,.nxt-topbar-actions,.bc-topbar-actions){
    justify-content: flex-start;
  }
  :where(.page-title-box,.panel-page-heading,.module-title-row,.badger-page-title,.bc-page-title){
    padding-left: 12px;
    padding-right: 12px;
  }
}
