/* ═══════════════════════════════════════════
   Huakings Top Navigation v2.0
   ─────────────────────────
   Full-feature top nav replacing Cockpit sidebar.
   8 primary links + "更多" dropdown.
   Sidebar, toggle, user dropdown all hidden.
   Fixes: max-width constraint, :focus-visible a11y.
   ═══════════════════════════════════════════ */

/* ── Masthead — positioning context, taller for dropdowns ── */
.pf-v6-c-masthead {
  position: relative !important;
  min-height: 52px !important;
  overflow: visible !important;
}

/* ═══════════════════════════════════════════
   TOPNAV CONTAINER — centered, max-width safe
   ═══════════════════════════════════════════ */
#huakings-topnav {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  display: flex !important;
  align-items: center !important;
  gap: 2px !important;
  white-space: nowrap !important;
  z-index: 200 !important;
  pointer-events: auto !important;
  /* Fix #1: max-width prevents overlap with right utilities */
  max-width: calc(100% - 360px) !important;
}

/* ── Individual nav items (links + dropdown button) ── */
.huakings-topnav-item {
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  color: var(--pf-t--global--text--color--regular, #d0d0d0) !important;
  text-decoration: none !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  white-space: nowrap !important;
  transition: background 0.2s ease, color 0.2s ease !important;
  cursor: pointer !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  border: 1px solid transparent !important;
  line-height: 1.3 !important;
  background: transparent !important;
  flex-shrink: 0 !important;
}

/* ── Icon ── */
.huakings-topnav-icon {
  font-size: 13px !important;
  line-height: 1 !important;
  opacity: 0.85;
}

/* ── Label ── */
.huakings-topnav-label {
  letter-spacing: 0.2px !important;
}

/* ── Hover ── */
.huakings-topnav-item:hover {
  background: rgba(255,255,255,0.10) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,0.15) !important;
}

/* ── Fix #2: Keyboard focus visible ── */
.huakings-topnav-item:focus-visible {
  outline: 2px solid #4fc3f7 !important;
  outline-offset: 2px !important;
  border-color: rgba(79,195,247,0.5) !important;
}

/* ── Active / current page ── */
.huakings-topnav-item.active,
.huakings-topnav-item[aria-current="page"] {
  background: rgba(79,195,247,0.15) !important;
  color: #4fc3f7 !important;
  border-color: rgba(79,195,247,0.35) !important;
}
.huakings-topnav-item.active .huakings-topnav-icon { opacity: 1; }
.huakings-topnav-item.active:hover {
  background: rgba(79,195,247,0.22) !important;
  border-color: rgba(79,195,247,0.5) !important;
}

/* ═══════════════════════════════════════════
   "更多" DROPDOWN
   ═══════════════════════════════════════════ */

/* ── Dropdown wrapper ── */
.htk-dropdown {
  position: relative !important;
  display: inline-flex !important;
  flex-shrink: 0 !important;
}

/* ── "更多" button ── */
.htk-more-btn {
  gap: 2px !important;
  padding-right: 5px !important;
}
.htk-more-arrow {
  font-size: 8px !important;
  margin-left: 1px !important;
  transition: transform 0.2s ease !important;
}
.htk-more-btn:hover .htk-more-arrow {
  transform: translateY(1px) !important;
}

/* ── Dropdown menu panel ── */
.htk-more-menu {
  display: none !important;
  position: absolute !important;
  top: 100% !important;
  right: 0 !important;
  margin-top: 4px !important;
  min-width: 140px !important;
  background: #1b1d21 !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
  z-index: 9999 !important;
  padding: 4px !important;
  flex-direction: column !important;
}

/* Open state */
.htk-more-menu.htk-open {
  display: flex !important;
}

/* ── Dropdown items ── */
.htk-more-item {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 8px 12px !important;
  border-radius: 4px !important;
  color: #d0d0d0 !important;
  text-decoration: none !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  transition: background 0.15s ease !important;
  border: none !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
.htk-more-item:hover {
  background: rgba(255,255,255,0.08) !important;
  color: #fff !important;
}
.htk-more-item.active {
  background: rgba(79,195,247,0.12) !important;
  color: #4fc3f7 !important;
}
.htk-more-item:focus-visible {
  outline: 2px solid #4fc3f7 !important;
  outline-offset: -2px !important;
}

/* ═══════════════════════════════════════════
   HIDE SIDEBAR, TOGGLE, USER DROPDOWN
   (Also injected via JS as inline styles,
    these are the CSS-level backups)
   ═══════════════════════════════════════════ */
#nav-system { display: none !important; }
#sidebar-toggle { display: none !important; }
#sidebar-hover-trigger { display: none !important; }
#host-toggle { display: none !important; }
.pf-v6-c-page__sidebar { display: none !important; }

/* Content fills full width */
#main.page {
  grid-template-columns: 0 0 1fr !important;
  transition: none !important;
}
#content {
  margin-left: 0 !important;
  width: 100% !important;
}

/* ═══════════════════════════════════════════
   MOBILE — 4 items only: 概览 文件 终端 更多
   Show session dropdown (#host-toggle) for logout/settings.
   Hide FAB, hide non-essential items.
   Desktop layout unchanged (all 8+4 visible).
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Hide the blue FAB button (from huakings-cockpit.js v13) */
  #huakings-fab { display: none !important; }

  /* Show session/user dropdown on mobile — needed for logout/settings */
  #host-toggle {
    display: flex !important;
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 201 !important;
    height: 44px !important;
    min-width: 44px !important;
    padding: 4px 8px !important;
    font-size: 13px !important;
  }
  #host-toggle .pf-v6-c-menu-toggle__text,
  #host-toggle .pf-v6-c-select__toggle-text {
    font-size: 12px !important;
  }

  /* Hide overlay menu and backdrop too */
  #huakings-menu-overlay { display: none !important; }
  #sidebar-backdrop { display: none !important; }

  /* Reset topnav for mobile */
  #huakings-topnav {
    gap: 4px !important;
    max-width: none !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
  }

  /* ═══ Hide 5 non-essential primary items on mobile ═══ */
  #huakings-topnav > a[href="/cockpit/system/logs"],
  #huakings-topnav > a[href="/cockpit/storage"],
  #huakings-topnav > a[href="/cockpit/network"],
  #huakings-topnav > a[href="/cockpit/system/services"],
  #huakings-topnav > a[href="/cockpit/updates"] {
    display: none !important;
  }

  /* ═══ The 3 visible primary links + dropdown button — show labels ═══ */
  #huakings-topnav > a.huakings-topnav-item,
  .htk-more-btn {
    padding: 5px 8px !important;
    gap: 3px !important;
    font-size: 12px !important;
  }
  .huakings-topnav-icon { font-size: 14px !important; }
  /* Show labels on mobile (only 4 items, plenty of room) */
  #huakings-topnav > a.huakings-topnav-item .huakings-topnav-label,
  .htk-more-btn .huakings-topnav-label {
    display: inline !important;
  }

  /* Dropdown items: show labels */
  .htk-more-item .huakings-topnav-label {
    display: inline !important;
  }

  /* Wider dropdown on mobile for touch */
  .htk-more-menu {
    min-width: 160px !important;
    right: -20px !important;
    /* Prevent dropdown from falling off-screen */
    max-height: 240px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin !important;
  }
  /* Open upward when near bottom of screen */
  .htk-more-menu.htk-dropup {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 4px !important;
  }
  .htk-more-item {
    padding: 12px 16px !important;
    font-size: 13px !important;
  }

  /* Hide secondary toolbar items (Help, Session, Limited access)
     to prevent overlap with nav on narrow screens.
     Our topnav is a direct child of masthead, not inside toolbar,
     so hiding toolbar children does not affect it. */
  .ct-topnav-content .pf-v6-c-toolbar__content-section {
    display: none !important;
  }

  /* Click-to-toggle only (no hover auto-open) */
  .htk-dropdown:hover .htk-more-menu {
    /* disabled on mobile */;
  }

  /* Hide Cockpit terminal font-size toolbar — maximize screen area */
  #system-terminal-page .pf-v6-c-toolbar__group:first-of-type,
  #system-terminal-page button[aria-label*="Font"],
  #system-terminal-page button[aria-label*="font"],
  #system-terminal-page button[aria-label*="字体"],
  #system-terminal-page button[aria-label*="增大"],
  #system-terminal-page button[aria-label*="减小"] {
    display: none !important;
  }
}

/* ── Small phones ── */
@media (max-width: 480px) {
  #huakings-topnav > a.huakings-topnav-item,
  .htk-more-btn {
    padding: 5px 6px !important;
    font-size: 11px !important;
  }
  .huakings-topnav-icon { font-size: 13px !important; }
  .htk-more-item { padding: 12px 14px !important; font-size: 13px !important; }
  .htk-more-menu { min-width: 150px !important; right: -10px !important; }
}

/* ═══════════════════════════════════════════
   LOGIN PAGE — cleaner look
   ═══════════════════════════════════════════ */

/* Cleaner background */
.login-pf {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
}

/* Hidden: banner, brand, badge */
.login-pf #banner,
.login-pf #brand,
.login-pf #badge {
  display: none !important;
}

/* Card styling */
.login-pf .container {
  max-width: 380px !important;
  margin: 0 auto !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.login-pf .container-body {
  background: rgba(255,255,255,0.06) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 16px !important;
  padding: 36px 32px 28px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3) !important;
  animation: htkFadeIn 0.4s ease-out !important;
}

@keyframes htkFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-pf .form-group { margin-bottom: 16px !important; }

.login-pf .control-label {
  font-size: 13px !important;
  color: rgba(255,255,255,0.7) !important;
  font-weight: 500 !important;
  margin-bottom: 5px !important;
}

.login-pf .form-control {
  background: rgba(255,255,245,0.95) !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-size: 15px !important;
  color: #1a1a2e !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
}

.login-pf .form-control:focus {
  border-color: #4fc3f7 !important;
  box-shadow: 0 0 0 3px rgba(79,195,247,0.25) !important;
  outline: none !important;
}

.login-pf .login-button {
  width: 100% !important;
  padding: 11px 20px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #4fc3f7, #0288d1) !important;
  border: none !important;
  color: #fff !important;
  letter-spacing: 0.5px !important;
  transition: opacity 0.2s, transform 0.15s !important;
}

.login-pf .login-button:hover {
  opacity: 0.9 !important;
  transform: translateY(-1px) !important;
}

.login-pf .login-button:focus-visible {
  outline: 2px solid #4fc3f7 !important;
  outline-offset: 2px !important;
}

/* Hide clutter */
.login-pf #get-out-link,
.login-pf .container-footer,
.login-pf .unsupported-browser {
  display: none !important;
}

.login-pf #option-group {
  text-align: center !important;
  margin-top: 10px !important;
}

.login-pf #show-other-login-options {
  color: rgba(255,255,255,0.4) !important;
  font-size: 12px !important;
  text-decoration: none !important;
}
