/* StreamCore 2.5.9 - UI Theme + Route Isolation FIX6
   - real local country flags (no platform emoji fallback)
   - dashboard injection is visible only on /dashboard and is torn down on route leave
   - hides legacy Dashboard while R6 is mounting to prevent old/new flash
   - Light/Dark parity for global topbar/nav/panels/forms without changing routes/data
*/

/* Never allow Dashboard runtime fragments to survive outside Dashboard. */
html:not(.sc-dashboard-route):not(.sc-dashboard-route-pending) #sc-dashboard-v2,
html:not(.sc-dashboard-route):not(.sc-dashboard-route-pending) #sc-location-panel { display:none !important; }
html.sc-dashboard-route-pending:not(.sc-dashboard-runtime-ready) .dashboard-board { opacity:0 !important; pointer-events:none !important; }
html.sc-dashboard-route-pending .dashboard-board > .stat-card,
html.sc-dashboard-route-pending .dashboard-board > .dashboard-ops-panel,
html.sc-dashboard-route-pending .dashboard-board > .hot-panel,
html.sc-dashboard-route-pending .dashboard-board > .dashboard-imports-panel { display:none !important; }
html.sc-dashboard-runtime-ready .dashboard-board { opacity:1 !important; transition:opacity .10s ease !important; }

/* Local PNG flags are deterministic on Windows/Linux; never show BR/US regional letters. */
.sc-country-flag { overflow:hidden !important; padding:0 !important; background:transparent !important; }
.sc-country-flag img { display:block !important; width:100% !important; height:100% !important; object-fit:cover !important; object-position:center !important; border:0 !important; border-radius:4px !important; }
.xui-shell.theme-light .sc-country-flag { background:#fff !important; }

/* App.vue already contains Online/Users/Live/Net labels. Disable historical generated labels. */
.xui-shell .header-stats .top-counter::before { content:none !important; display:none !important; }

/* Global layout containment: every route must stay inside the viewport. */
.xui-shell, .xui-shell *, .login-shell, .login-shell * { box-sizing:border-box; }
.xui-shell { min-width:0 !important; max-width:100vw !important; overflow-x:hidden !important; }
.xui-shell .xui-workspace { min-width:0 !important; width:100% !important; max-width:100% !important; }
.xui-shell .xui-panel,
.xui-shell .main-server-card,
.xui-shell .stat-card,
.xui-shell .profile-modern-card,
.xui-shell .settings-layout,
.xui-shell .server-table-panel,
.xui-shell .import-wizard-panel { max-width:100% !important; }
.xui-shell .table-wrap,
.xui-shell .compact-table,
.xui-shell .service-scroll,
.xui-shell .cache-items-table { max-width:100% !important; overflow:auto !important; }
.xui-shell img, .xui-shell svg, .xui-shell canvas { max-width:100%; }

/* LIGHT: topbar and controls. */
.xui-shell.theme-light .xui-topbar.header-main {
  background:linear-gradient(90deg,#f8fbff 0%,#eef6ff 58%,#e7f1fd 100%) !important;
  border-bottom-color:#cfdeee !important;
  color:#21374f !important;
}
.xui-shell.theme-light .xui-brand,
.xui-shell.theme-light .xui-brand strong,
.xui-shell.theme-light .xui-brand span { color:#1d3855 !important; text-shadow:none !important; }
.xui-shell.theme-light .xui-live-counters .top-counter,
.xui-shell.theme-light .header-stats .top-counter {
  background:#fff !important; border-color:#d5e1ed !important; color:#29445f !important;
}
.xui-shell.theme-light .xui-live-counters .top-counter b,
.xui-shell.theme-light .xui-live-counters .top-counter small,
.xui-shell.theme-light .sc-top-counter-label { color:#29445f !important; }
.xui-shell.theme-light .xui-live-counters .top-counter small { color:#657b91 !important; }
.xui-shell.theme-light .top-search-button,
.xui-shell.theme-light .alert-bell-button,
.xui-shell.theme-light .user-button.clean-user-button {
  background:#fff !important; border-color:#d5e1ed !important; color:#263f59 !important;
}
.xui-shell.theme-light .alert-bell-button i,
.xui-shell.theme-light .user-button.clean-user-button i { color:#263f59 !important; }

/* LIGHT: complete top navigation readability, including accent-colored topbar themes. */
.xui-shell.theme-light .xui-nav.nav-rework,
.xui-shell.theme-light #xui-main-nav:not(.nav-rework-original-hidden) {
  background:#f8fbff !important; border-bottom-color:#d6e3f0 !important; color:#263f59 !important;
}
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item > button,
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item > button .nav-text,
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item > button .nav-chevron,
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item > button .nav-fa {
  color:#2b455f !important; text-shadow:none !important;
}
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item.active > button,
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item:hover > button,
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item:focus-within > button {
  color:#173450 !important;
  background:linear-gradient(180deg,rgba(var(--theme-accent-rgb,47,130,255),.15),rgba(var(--theme-accent-rgb,47,130,255),.05)) !important;
}
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item.active > button .nav-text,
.xui-shell.theme-light .xui-nav.nav-rework > .nav-item:hover > button .nav-text { color:#173450 !important; }
.xui-shell.theme-light .sc-nav-live-clock { background:#fff !important; border-color:#d5e1ed !important; color:#5b728a !important; }
.xui-shell.theme-light .sc-nav-live-clock b { color:#203b56 !important; }

/* LIGHT: flyouts, search, alerts and user menus. */
.xui-shell.theme-light .nav-dropdown,
.xui-shell.theme-light .nav-flyout,
.xui-shell.theme-light .user-dropdown,
.xui-shell.theme-light .top-search-panel,
.xui-shell.theme-light .alert-center-panel {
  background:#fff !important; color:#263f59 !important; border-color:#d5e1ed !important;
  box-shadow:0 18px 42px rgba(31,55,80,.16) !important;
}
.xui-shell.theme-light .top-search-panel input { background:#fff !important; color:#21374f !important; border-color:#ccdbea !important; }
.xui-shell.theme-light .alert-center-panel header,
.xui-shell.theme-light .alert-tabs { border-color:#dce6f0 !important; }
.xui-shell.theme-light .alert-center-panel strong,
.xui-shell.theme-light .alert-center-panel p,
.xui-shell.theme-light .alert-center-panel button,
.xui-shell.theme-light .user-dropdown button { color:#29445f !important; }
.xui-shell.theme-light .alert-center-panel small,
.xui-shell.theme-light .alert-empty span { color:#6b8096 !important; }
.xui-shell.theme-light .alert-item { background:#f8fbff !important; border-color:#dce6f0 !important; }

/* LIGHT: generic page surfaces and form readability. Avoid recoloring semantic badges/buttons. */
.xui-shell.theme-light .xui-workspace { background:#edf5fc !important; color:#263f59 !important; }
.xui-shell.theme-light .xui-panel,
.xui-shell.theme-light .main-server-card,
.xui-shell.theme-light .stat-card,
.xui-shell.theme-light .profile-modern-card,
.xui-shell.theme-light .profile-panel,
.xui-shell.theme-light .settings-layout,
.xui-shell.theme-light .settings-side,
.xui-shell.theme-light .server-table-panel,
.xui-shell.theme-light .import-wizard-panel {
  background:#fff !important; border-color:#d7e3ef !important; color:#263f59 !important;
}
.xui-shell.theme-light .page-title-row h1,
.xui-shell.theme-light .panel-head h2,
.xui-shell.theme-light .panel-head h3,
.xui-shell.theme-light .profile-page h2,
.xui-shell.theme-light .xui-workspace h1,
.xui-shell.theme-light .xui-workspace h2,
.xui-shell.theme-light .xui-workspace h3 { color:#1e3852 !important; text-shadow:none !important; }
.xui-shell.theme-light label,
.xui-shell.theme-light .profile-form label > span,
.xui-shell.theme-light .data-table-tools label { color:#334e68 !important; }
.xui-shell.theme-light input,
.xui-shell.theme-light select,
.xui-shell.theme-light textarea {
  background:#fff !important; color:#233b54 !important; border-color:#c8d8e7 !important;
}
.xui-shell.theme-light input::placeholder,
.xui-shell.theme-light textarea::placeholder { color:#8496a9 !important; }
.xui-shell.theme-light table { color:#29445f !important; }
.xui-shell.theme-light th { color:#314d68 !important; background:#f2f7fc !important; }
.xui-shell.theme-light td { color:#36516b !important; border-color:#e0e9f2 !important; }

/* Keep Dashboard-specific visuals scoped to Dashboard even if stale DOM survives for a frame. */
html:not(.sc-dashboard-route):not(.sc-dashboard-route-pending) .sc-dashboard-v2,
html:not(.sc-dashboard-route):not(.sc-dashboard-route-pending) .sc-location-panel { visibility:hidden !important; }

@media (min-width:2000px) {
  .xui-shell .xui-workspace { padding-left:clamp(22px,2.5vw,64px) !important; padding-right:clamp(22px,2.5vw,64px) !important; }
}
@media (max-width:1100px) {
  .xui-shell .xui-nav.nav-rework { overflow-x:auto !important; overflow-y:visible !important; scrollbar-width:thin; }
  .xui-shell .xui-nav.nav-rework > .nav-item { flex:0 0 auto !important; }
  .xui-shell .profile-shell { max-width:calc(100vw - 24px) !important; }
}
@media (max-width:760px) {
  .xui-shell .xui-workspace { padding-left:10px !important; padding-right:10px !important; }
  .xui-shell .xui-panel, .xui-shell .main-server-card, .xui-shell .stat-card { border-radius:6px !important; }
}
