/*
 * MHQ Panel — Professional UI v5
 * Visual and layout layer only. All existing functional IDs remain unchanged.
 * Primary goals: one predictable workspace scroll, no trapped form regions,
 * improved information hierarchy, polished MHQ blue/cyan identity.
 */

:root {
  --bg: #05080d;
  --bg-elevated: #080d14;
  --surface: #0b1119;
  --surface-2: #0e1621;
  --surface-3: #111c29;
  --surface-hover: #131f2d;
  --border: rgba(144, 171, 201, .12);
  --border-strong: rgba(79, 159, 255, .32);
  --text: #f4f7fb;
  --text-soft: #c7d0dc;
  --muted: #7e8b9b;
  --muted-2: #566372;
  --blue: #168cff;
  --blue-strong: #0878e8;
  --cyan: #54d3ff;
  --green: #42d989;
  --yellow: #f0c560;
  --red: #f26f7d;
  --purple: #a97cff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 8px 24px rgba(0,0,0,.18);
  --shadow-md: 0 18px 48px rgba(0,0,0,.28);
  --focus: 0 0 0 3px rgba(22,140,255,.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--bg); }
body {
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 82% -8%, rgba(22,140,255,.09), transparent 28%),
    radial-gradient(circle at 18% 12%, rgba(84,211,255,.035), transparent 22%),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -.006em;
}

::selection { background: rgba(22,140,255,.30); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: #263649 #0a1017; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: #0a1017; }
*::-webkit-scrollbar-thumb {
  background: #263649;
  border: 3px solid #0a1017;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: #34506c; }

/* ---------- Application frame / scroll model ---------- */
.app-shell {
  width: 100%;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  position: relative;
  top: auto;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 18px 14px 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #080d14 0%, #070b11 100%);
  box-shadow: 12px 0 40px rgba(0,0,0,.16);
  z-index: 6;
}

.main {
  width: auto;
  max-width: none;
  min-width: 0;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 0 28px 56px;
  scrollbar-gutter: stable;
}

.page { min-width: 0; padding-bottom: 22px; }
.page.active { display: block; }

/* ---------- Brand ---------- */
.brand {
  display: grid;
  gap: 7px;
  align-items: center;
  padding: 2px 8px 20px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.055);
}
.brand-logo {
  display: block;
  width: 218px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 7px 18px rgba(0,100,210,.16));
}
.brand-copy { display: none; }
.brand-caption {
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: .11em;
  text-transform: uppercase;
  font-weight: 750;
}

/* ---------- Navigation ---------- */
.nav { display: grid; gap: 3px; }
.nav-label {
  margin: 14px 10px 5px;
  padding: 0;
  color: #536171;
  font-size: 9px;
  line-height: 1;
  letter-spacing: .15em;
  text-transform: uppercase;
  font-weight: 800;
}
.nav-item {
  position: relative;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #929eac;
  font-size: 12.5px;
  font-weight: 620;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.nav-item:hover {
  color: #e7edf5;
  background: rgba(255,255,255,.028);
  border-color: rgba(255,255,255,.04);
}
.nav-item.active {
  color: #f6f9ff;
  background: linear-gradient(90deg, rgba(22,140,255,.13), rgba(22,140,255,.045));
  border-color: rgba(22,140,255,.14);
  box-shadow: inset 2px 0 0 var(--blue);
}
.nav-icon {
  width: 20px !important;
  height: 20px;
  flex: 0 0 20px;
  display: grid;
  place-items: center;
  color: #6e7d8e !important;
}
.nav-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-item.active .nav-icon { color: #69bdff !important; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 8px 2px;
  border-top: 1px solid rgba(255,255,255,.055);
}
.connection-pill {
  padding: 8px 9px;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.055);
  border-radius: 9px;
  background: rgba(255,255,255,.018);
  color: #94a0ad;
  font-size: 11px;
}
.connection-pill i { width: 7px; height: 7px; }
.mini-copy { margin-top: 8px; color: #4d5967; font-size: 10px; line-height: 1.45; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 92px;
  margin: 0 -28px 18px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(255,255,255,.055);
  background: rgba(5,8,13,.90);
  backdrop-filter: blur(18px) saturate(1.1);
}
.topbar::before,
.topbar::after { display: none !important; }
.topbar h1 {
  margin: 3px 0 0;
  color: #f7f9fc;
  font-family: inherit;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -.034em;
  text-transform: none;
  text-shadow: none;
  font-weight: 720;
}
.topbar h1::after { display: none !important; }
.eyebrow {
  color: #687789;
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
}
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Panels / cards ---------- */
.panel,
.preview-card,
.stat-card {
  position: relative;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(13,20,29,.98), rgba(10,16,24,.98));
  box-shadow: var(--shadow-sm);
}
.panel::before,
.preview-card::before,
.stat-card::before { display: none !important; }
.panel { padding: 18px; }
.panel:hover,
.preview-card:hover,
.stat-card:hover { border-color: rgba(144,171,201,.16); }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.panel-head h2 {
  margin: 4px 0 0;
  color: #f2f5f9;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.022em;
}
.panel-intro { color: var(--muted); }

.notice {
  margin: 0 0 18px;
  padding: 11px 13px;
  gap: 9px;
  border: 1px solid rgba(22,140,255,.13);
  border-left: 3px solid rgba(22,140,255,.72);
  border-radius: 10px;
  background: rgba(22,140,255,.045);
  color: #9aa8b8;
  box-shadow: none;
  font-size: 12px;
}
.notice strong { color: #dfeafa; }
.notice.subtle { background: rgba(255,255,255,.016); border-left-width: 1px; }

.stat-grid { gap: 12px; margin-bottom: 16px; }
.stat-card {
  min-height: 110px;
  padding: 17px;
  background: linear-gradient(180deg, #0f1721, #0b1119);
}
.stat-card span { color: #6c7988; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; }
.stat-card strong { color: #f5f7fa; font-size: 22px; font-weight: 700; }
.stat-card small { color: #5e6b79; }
.grid-2 { gap: 16px; margin-bottom: 16px; }
.feature-list > div,
.subcard,
.security-box {
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 10px;
  background: rgba(255,255,255,.014);
}
.feature-list > div { padding: 11px 12px; }
.feature-list b { color: #e5eaf0; }
.feature-list span { color: #788595; }
.timeline span { background: rgba(22,140,255,.08); color: #7ec5ff; border: 1px solid rgba(22,140,255,.09); }

/* ---------- Controls ---------- */
.btn {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.085);
  border-radius: 8px;
  background: #131b24;
  color: #dce3eb;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
  font-size: 12px;
  font-weight: 670;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.14); background: #18222d; }
.btn.primary {
  color: #fff;
  border-color: rgba(73,168,255,.62);
  background: linear-gradient(180deg, #188fff, #0877e2);
  box-shadow: 0 6px 18px rgba(0,95,205,.18), inset 0 1px 0 rgba(255,255,255,.16);
}
.btn.primary:hover { background: linear-gradient(180deg, #2699ff, #0b7ce9); border-color: rgba(112,188,255,.78); }
.btn.ghost { background: transparent; color: #a8b2be; border-color: rgba(255,255,255,.07); }
.btn.ghost:hover { background: rgba(255,255,255,.03); color: #edf2f8; }
.btn.danger-soft { background: rgba(242,111,125,.055); border-color: rgba(242,111,125,.14); color: #efa0a9; }
.btn.danger-soft:hover { background: rgba(242,111,125,.09); border-color: rgba(242,111,125,.25); }
.btn.small { min-height: 31px; padding: 6px 9px; font-size: 11px; }
.btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible { outline: none; box-shadow: var(--focus); }

.input,
input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid rgba(144,171,201,.12);
  border-radius: 8px;
  background: #070c12;
  color: #edf1f6;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.20);
}
textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
  overflow: auto;
}
input::placeholder,
textarea::placeholder { color: #4c5866; }
input:focus,
textarea:focus,
select:focus { border-color: rgba(22,140,255,.58); box-shadow: var(--focus); }
.field { gap: 6px; margin-bottom: 13px; }
.field > span { color: #cdd5df; font-size: 11px; font-weight: 680; }
.field small,
.switch-row small,
.section-title-row small,
.helper-copy { color: #667382; font-size: 10.5px; }
.row-2 { gap: 10px; }
.row-3 { gap: 10px; }
.row-4 { gap: 10px; }
.form-section { margin: 16px 0; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.055); }
.form-section h3,
.section-title-row h3 { color: #e7ebf0; font-size: 12.5px; font-weight: 700; }

.switch-row {
  min-height: 50px;
  margin-bottom: 12px;
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,.055);
  border-radius: 9px;
  background: rgba(255,255,255,.012);
}
.switch-row:hover { border-color: rgba(255,255,255,.09); }
.switch-row > span { color: #c4ccd6; font-size: 11px; }
.switch-row i { width: 36px; height: 20px; background: #202a35; }
.switch-row i::after { width: 14px; height: 14px; background: #8894a2; }
.switch-row input:checked + i { background: rgba(22,140,255,.46); }
.switch-row input:checked + i::after { transform: translateX(16px); background: #fff; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid rgba(255,255,255,.065);
  border-radius: 9px;
  background: #080d13;
}
.segmented button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #738090;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.segmented button.active {
  color: #eef5ff;
  background: rgba(22,140,255,.12);
  box-shadow: inset 0 0 0 1px rgba(22,140,255,.16);
}

/* ---------- Designers: no trapped scroll / no covered controls ---------- */
.designer-layout {
  display: grid;
  grid-template-columns: minmax(540px, 1.22fr) minmax(340px, .78fr);
  gap: 18px;
  align-items: start;
}
.editor-panel {
  position: relative;
  padding-bottom: 18px;
  overflow: visible;
}
.preview-stack {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 108px;
  align-self: start;
  overflow: visible;
}
.preview-card { padding: 13px; overflow: hidden; }
.preview-label { margin-bottom: 10px; color: #697789; font-size: 9px; letter-spacing: .13em; }
.save-state { border-color: rgba(255,255,255,.07); background: rgba(255,255,255,.015); color: #73808f; }
.save-state.saved { color: #8ddcae; border-color: rgba(66,217,137,.18); background: rgba(66,217,137,.04); }

.sticky-actions {
  position: sticky;
  left: auto;
  right: auto;
  bottom: 10px;
  z-index: 7;
  margin: 22px -10px -8px;
  padding: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 11px;
  background: rgba(8,13,20,.94);
  box-shadow: 0 12px 34px rgba(0,0,0,.28);
  backdrop-filter: blur(16px);
}

.premium-section,
.format-composer,
.rank-style-builder,
.premium-toolbar,
.designer-toolbar {
  border-color: rgba(255,255,255,.06) !important;
  background: rgba(255,255,255,.012) !important;
  border-radius: 11px !important;
}
.quick-stat-grid { gap: 7px; }
.stat-preset,
.quick-stat-grid .stat-preset {
  border-color: rgba(255,255,255,.065) !important;
  background: #0b121a !important;
  color: #9dabb9 !important;
  border-radius: 8px !important;
}
.stat-preset:hover,
.quick-stat-grid .stat-preset:hover { border-color: rgba(22,140,255,.30) !important; color: #eef5ff !important; background: #0e1a26 !important; }

.minecraft-window,
.minecraft-scene,
.scoreboard-preview,
.chat-preview,
.rex-minecraft-scene {
  border: 1px solid rgba(255,255,255,.065) !important;
  border-radius: 9px !important;
  box-shadow: inset 0 0 50px rgba(0,0,0,.32) !important;
}

/* ---------- RexWelcome ---------- */
.rex-layout .editor-panel { min-width: 0; }
.rex-editor-tab { min-width: 0; }
.rex-editor-tab textarea { width: 100%; max-width: 100%; }
.page-subtabs { margin-bottom: 16px; }
.rex-preview-card { overflow: hidden; }
.rex-minecraft-scene { min-height: 480px; }
.rex-chat { max-height: 44%; overflow: hidden; }

/* ---------- Player management ---------- */
.player-management {
  display: grid;
  grid-template-columns: 308px minmax(0,1fr);
  gap: 16px;
  align-items: start;
}
.player-directory-panel {
  position: static;
  top: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
}
.player-directory { overflow: visible; max-height: none; }
.player-directory-item { min-height: 47px; border-radius: 8px; }
.player-directory-item:hover { background: rgba(255,255,255,.025); }
.player-directory-item.active {
  background: rgba(22,140,255,.08);
  border-color: rgba(22,140,255,.12);
  box-shadow: inset 2px 0 0 var(--blue);
}
.player-status-dot.online { background: var(--green); box-shadow: 0 0 8px rgba(66,217,137,.48); }
.player-summary-panel { background: linear-gradient(110deg, rgba(22,140,255,.035), transparent 40%), linear-gradient(180deg, #0f1721, #0b1119); }
.player-avatar { background: linear-gradient(145deg, #2a9cff, #0a6ecb); border: 1px solid rgba(113,190,255,.38); box-shadow: 0 8px 24px rgba(0,90,190,.16); }
.player-action-grid { gap: 14px; }
.action-card { background: linear-gradient(180deg, #0e1620, #0b1119); }
.player-action-log { max-height: none; overflow: visible; }

/* ---------- Plugin manager ---------- */
.plugin-manager {
  display: grid;
  grid-template-columns: 282px minmax(0,1fr);
  gap: 16px;
  min-height: 0;
  align-items: start;
}
.plugin-list-panel { padding-right: 18px; }
.plugin-list {
  display: grid;
  gap: 3px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}
.plugin-item { border: 1px solid transparent; border-radius: 8px; color: #8e9aa8; }
.plugin-item:hover { background: rgba(255,255,255,.025); color: #e2e8ef; }
.plugin-item.active { background: rgba(22,140,255,.08); color: #edf5ff; border-color: rgba(22,140,255,.10); box-shadow: inset 2px 0 0 var(--blue); }
.config-panel { min-width: 0; overflow: visible; }
.config-group { border-color: rgba(255,255,255,.055); border-radius: 9px; }
.config-setting { grid-template-columns: minmax(170px,.65fr) minmax(240px,1.35fr); }
.raw-config textarea { min-height: 560px; }

/* ---------- Console ---------- */
.live-console-panel { background: linear-gradient(180deg, #0d151f, #090f16); }
.console-stream,
.command-history {
  border-color: rgba(255,255,255,.06) !important;
  background: #05090e !important;
}
.console-stream {
  height: min(520px, 52vh);
  min-height: 320px;
  overflow: auto;
}
.command-history { max-height: 130px; overflow: auto; }
.command-bar { border-color: rgba(22,140,255,.20); background: #060b10; }

/* ---------- Overview / plugins ---------- */
.plugin-grid { gap: 8px; }
.plugin-chip { border-color: rgba(255,255,255,.05); background: rgba(255,255,255,.012); border-radius: 9px; }
.plugin-chip:hover { border-color: rgba(22,140,255,.14); background: rgba(22,140,255,.025); transform: none; }
.plugin-chip b { color: #dce3eb; }

/* ---------- Modal ---------- */
.modal {
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  background: #0c131c;
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0,0,0,.62);
}
.modal::backdrop { background: rgba(1,4,8,.76); backdrop-filter: blur(8px); }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .app-shell { grid-template-columns: 230px minmax(0,1fr); }
  .brand-logo { width: 188px; }
  .designer-layout { grid-template-columns: minmax(500px,1fr) minmax(300px,.72fr); }
  .plugin-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 78px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-items: center; padding-inline: 0; }
  .brand-logo {
    content: url("assets/mhq-panel-icon.png");
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
  }
  .nav-label, .mini-copy { display: none; }
  .nav-item { justify-content: center; width: 56px; margin-inline: auto; font-size: 0; padding-inline: 0; }
  .nav-icon { width: 22px !important; height: 22px; flex-basis: 22px; }
  .nav-icon svg { width: 19px; height: 19px; }
  .connection-pill { justify-content: center; padding: 9px 0; }
  .connection-pill span { display: none; }
  .sidebar-footer { padding-inline: 0; }
  .designer-layout { grid-template-columns: 1fr; }
  .preview-stack { position: static; top: auto; }
  .player-management { grid-template-columns: 1fr; }
  .plugin-manager { grid-template-columns: 1fr; }
  .plugin-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .plugin-list-panel { padding-right: 18px; }
}

@media (max-width: 720px) {
  html, body { height: auto; min-height: 100%; }
  body { overflow: auto; }
  .app-shell { display: block; height: auto; min-height: 100vh; overflow: visible; }
  .main { height: auto; min-height: 100vh; overflow: visible; padding: 0 12px 94px; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    height: 70px;
    min-height: 70px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    border-right: 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -12px 38px rgba(0,0,0,.30);
    z-index: 50;
  }
  .brand, .sidebar-footer, .nav-label { display: none; }
  .nav { display: flex; gap: 5px; min-width: max-content; }
  .nav-item { width: 52px; height: 52px; min-height: 52px; margin: 0; border-radius: 10px; }
  .nav-item.active { box-shadow: inset 0 0 0 1px rgba(22,140,255,.20); }
  .topbar {
    position: sticky;
    min-height: 82px;
    margin: 0 -12px 14px;
    padding: 0 14px;
  }
  .topbar h1 { font-size: 21px; }
  .top-actions .switch-row.compact { display: none; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-2, .row-2, .row-3, .row-4, .player-action-grid { grid-template-columns: 1fr; }
  .plugin-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .plugin-list { grid-template-columns: 1fr; }
  .config-setting { grid-template-columns: 1fr; gap: 8px; }
  .sticky-actions { bottom: 80px; margin-inline: -6px; }
  .panel { padding: 14px; }
  .rex-minecraft-scene { min-height: 420px; }
}

@media (max-width: 480px) {
  .stat-grid, .plugin-grid { grid-template-columns: 1fr; }
  .top-actions { gap: 5px; }
  .top-actions .btn { padding-inline: 9px; }
  .panel-head { align-items: flex-start; }
}
