/* Huakings Cockpit v12 — ▶ click-to-toggle sidebar + terminal maximize + mobile + grid fix */

/* ═══════════════════════════════════════════
   PAGE GRID — transition when sidebar toggles
   ═══════════════════════════════════════════ */
#main.page {
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ═══════════════════════════════════════════
   SIDEBAR TOGGLE — ▶ button on left edge
   ═══════════════════════════════════════════ */

/* Show sidebar-toggle container and position it as a toggle button */
#sidebar-toggle {
  display: flex !important;
  position: fixed !important;
  left: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  z-index: 9999 !important;
  transition: left 0.3s ease !important;
}
/* Push toggle button to the right when sidebar is open */
#sidebar-toggle.sb-tgl-open {
  left: 240px !important;
}

/* Style the toggle button — narrow vertical strip with ▶ */
#sidebar-toggle button,
#sidebar-toggle #nav-system-item {
  width: 22px !important;
  height: 56px !important;
  min-width: 22px !important;
  padding: 0 !important;
  border-radius: 0 8px 8px 0 !important;
  border: 1px solid var(--pf-t--global--border--color--default, #444) !important;
  border-left: none !important;
  background: var(--pf-t--global--background--color--primary--default, #1b1d21) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  opacity: 0.55;
  transition: opacity 0.2s ease, background 0.2s ease;
  color: #aaa !important;
}
#sidebar-toggle button:hover {
  opacity: 1;
  background: var(--pf-t--global--background--color--primary--hover, #2a2d33) !important;
}

/* Arrow icon inside toggle button */
#sidebar-toggle .sb-arrow {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  color: #ccc;
}

/* Hide original button text and icon when arrow is used */
#sidebar-toggle button .pf-v6-c-button__text,
#sidebar-toggle button .pf-v6-c-button__icon,
#sidebar-toggle #nav-system-item .pf-v6-c-button__text,
#sidebar-toggle #nav-system-item .pf-v6-c-icon {
  display: none !important;
}
#sidebar-toggle .sb-arrow {
  display: inline-block !important;
}

/* ═══════════════════════════════════════════
   SIDEBAR TRANSITIONS
   ═══════════════════════════════════════════ */
#nav-system {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease !important;
  will-change: transform;
}

/* Collapsed: sidebar slides left, out of flow */
#nav-system.sb-collapsed {
  transform: translateX(-100%) !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: fixed !important;
  z-index: 9998 !important;
}

/* Expanded: sidebar visible in flow */
#nav-system.sb-expanded {
  transform: translateX(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* ═══════════════════════════════════════════
   CONTENT AREA — full-width when collapsed
   ═══════════════════════════════════════════ */
#content {
  transition: margin-left 0.3s ease !important;
}

/* ═══════════════════════════════════════════
   MOBILE — sidebar overlay with backdrop
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
  #nav-system {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    z-index: 9998 !important;
    height: 100vh !important;
    width: 260px !important;
    max-width: 85vw !important;
    box-shadow: 2px 0 20px rgba(0,0,0,0.6) !important;
  }

  #nav-system.sb-collapsed {
    transform: translateX(-105%) !important;
  }

  #nav-system.sb-expanded {
    transform: translateX(0) !important;
  }

  #sidebar-toggle {
    top: 50% !important;
  }

  /* Backdrop overlay */
  body.sb-backdrop::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9997;
    pointer-events: auto;
  }

  /* Larger touch targets */
  #sidebar-toggle button,
  #sidebar-toggle #nav-system-item {
    width: 26px !important;
    height: 64px !important;
    min-width: 26px !important;
  }

  .pf-v6-c-nav__link {
    min-height: 48px !important;
    font-size: 14px !important;
  }
}

/* Even smaller phones */
@media (max-width: 480px) {
  #nav-system {
    width: 240px !important;
    max-width: 80vw !important;
  }
}

/* ═══════════════════════════════════════════
   TERMINAL MAXIMIZE — disabled
   ═══════════════════════════════════════════ */
#terminal-maximize-btn { display: none !important; }
#terminal-maximize-toast { display: none !important; }

/* ═══════════════════════════════════════════
   PAGE LAYOUT — reduce PF6 margins so content fills left edge
   ═══════════════════════════════════════════ */
/* Global: modest reduction */
.pf-v6-c-page__main-container {
  margin: 0 8px !important;
}
.pf-v6-c-page__main-section {
  padding: 8px 12px !important;
}
/* Terminal-specific: maximize fill — no extra spacing */
#system-terminal-page .pf-v6-c-page__main-container {
  margin: 0 !important;
  padding: 0 !important;
}
#system-terminal-page .pf-v6-c-page__main {
  margin: 0 !important;
  padding: 0 !important;
}
#system-terminal-page .pf-v6-c-page__main-body {
  padding: 0 !important;
}
#system-terminal-page .pf-v6-c-page__main-section {
  padding: 2px 4px !important;
}
/* Let terminal container stretch fully */
#system-terminal-page .ct-page-fill {
  width: 100% !important;
  height: 100% !important;
}

/* ═══════════════════════════════════════════
   GENERAL MOBILE TWEAKS
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .pf-v6-c-button {
    min-height: 40px !important;
    min-width: 40px !important;
  }
  .pf-v6-c-select__toggle {
    min-height: 40px !important;
  }
  .pf-v6-c-nav__link {
    min-height: 44px !important;
  }
}

/* ═══════════════════════════════════════════
   LOGIN PAGE — clean & minimal
   ═══════════════════════════════════════════ */
.login-pf {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
}

/* Hide banner completely */
.login-pf #banner {
  display: none !important;
}

/* Hide OS branding (Ubuntu logo) */
.login-pf #brand {
  display: none !important;
}

/* Hide badge */
.login-pf #badge {
  display: none !important;
}

/* Login card — compact & centered */
.login-pf .container {
  max-width: 380px !important;
  margin: 0 auto !important;
  padding: 0 !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;
}

/* Form elements — clean */
.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: 4px !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 button */
.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;
}

/* Cancel link */
.login-pf #get-out-link {
  display: none !important;
}

/* Other options link */
.login-pf #option-group {
  text-align: center !important;
  margin-top: 12px !important;
}

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

.login-pf #show-other-login-options:hover {
  color: rgba(255,255,255,0.7) !important;
}

/* Server group (connect to) */
.login-pf #server-group {
  margin-top: 4px !important;
}

/* Hide footer */
.login-pf .container-footer {
  display: none !important;
}

/* Error message — keep compact */
.login-pf #error-group {
  margin-bottom: 16px !important;
  border-radius: 8px !important;
}

/* Hide unsupported browser nag */
.login-pf .unsupported-browser {
  display: none !important;
}

/* Transition for card */
.login-pf .container-body {
  animation: loginFadeIn 0.4s ease-out !important;
}

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

/* ═══════════════════════════════════════════
   v13 FAB OVERLAY MENU — mobile-first
   ═══════════════════════════════════════════ */

/* ── FAB (Floating Action Button) ── */
#huakings-fab {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #4fc3f7, #0288d1) !important;
  border: none !important;
  color: #fff !important;
  font-size: 20px !important;
  line-height: 48px !important;
  text-align: center !important;
  cursor: pointer !important;
  z-index: 10000 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
  -webkit-tap-highlight-color: transparent !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}
#huakings-fab:active {
  transform: scale(0.92) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}
/* Hide FAB on desktop — ▶ sidebar toggle is sufficient */
@media (min-width: 901px) {
  #huakings-fab {
    display: none !important;
  }
}

/* ── Backdrop ── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9998;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

/* ── Menu Overlay ── */
#huakings-menu-overlay {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 75vh;
  background: #1b1d21;
  border-radius: 16px 16px 0 0;
  z-index: 9999;
  overflow-y: auto;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
  animation: menuSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}
@keyframes menuSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ── Menu Header ── */
.huakings-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #333;
  position: sticky;
  top: 0;
  background: #1b1d21;
  z-index: 1;
  border-radius: 16px 16px 0 0;
}
.huakings-menu-header span {
  font-size: 16px;
  font-weight: 600;
  color: #e0e0e0;
}
#huakings-menu-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
#huakings-menu-close:active {
  background: rgba(255,255,255,0.15);
}

/* ── Menu Items ── */
.huakings-menu-item {
  padding: 14px 20px;
  color: #ccc;
  font-size: 15px;
  border-bottom: 1px solid #2a2a2a;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.huakings-menu-item:active {
  background: rgba(255,255,255,0.06);
}
.huakings-menu-item:last-child {
  border-bottom: none;
  padding-bottom: 28px; /* safe area for home indicator */
}

/* ── Desktop Hover Trigger (left edge) ── */
@media (min-width: 901px) {
  #sidebar-hover-trigger {
    position: fixed;
    left: 0;
    top: 0;
    width: 8px;
    height: 100vh;
    z-index: 9990;
    cursor: pointer;
  }
}
@media (max-width: 900px) {
  #sidebar-hover-trigger {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════
   TERMINAL FIX — 文字选择 + 复制按钮
   ═══════════════════════════════════════════ */

/* 允许终端区域文字选择 */
.xterm, .xterm-screen, .xterm-viewport, .xterm-selection,
.xterm-decoration-overview-ruler, .xterm-link-layer,
#terminal, .ct-page-fill, #system-terminal-page {
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
}
.xterm-text-layer {
  user-select: text !important;
  -webkit-user-select: text !important;
  pointer-events: none !important;
}
.xterm canvas { pointer-events: auto !important; }

/* ── 浮动复制按钮 ── */
#htf-copy-btn {
  position: fixed !important;
  bottom: 16px !important;
  right: 16px !important;
  z-index: 10001 !important;
  padding: 8px 14px !important;
  background: rgba(30,30,30,0.88) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  border-radius: 8px !important;
  color: #ccc !important;
  font-size: 13px !important;
  font-family: sans-serif !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4) !important;
  white-space: nowrap !important;
}
#htf-copy-btn:hover {
  background: rgba(60,60,60,0.92) !important;
  border-color: rgba(255,255,255,0.35) !important;
  color: #fff !important;
  transform: translateY(-1px) !important;
}

/* ── 自动复制开关 ── */
#htf-auto-toggle {
  position: fixed !important;
  bottom: 54px !important;
  right: 16px !important;
  z-index: 10001 !important;
  padding: 4px 10px !important;
  background: rgba(30,30,30,0.8) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 6px !important;
  color: #aaa !important;
  font-size: 10px !important;
  font-family: sans-serif !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}
#htf-auto-toggle:hover { color: #fff !important; }
#htf-auto-toggle.htf-active { color: #4fc3f7 !important; }

/* ── Toast 通知 ── */
#htf-toast {
  position: fixed !important;
  bottom: 90px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 10002 !important;
  background: rgba(0,180,80,0.92) !important;
  color: #fff !important;
  padding: 7px 20px !important;
  border-radius: 20px !important;
  font-size: 13px !important;
  font-family: sans-serif !important;
  pointer-events: none !important;
  opacity: 0 !important;
  transition: opacity 0.25s ease !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;
}
