/* ============================================================
   topbar.css — Shared Site Header Styles
   Extracted from main.css & enhanced for 1-Row Compact Mobile.
   All rules here are TOPBAR-ONLY.
   DO NOT add game / modal / profile rules here.
   ============================================================ */

/* ── Height contract ─────────────────────────────────────── */
/* Desktop: logo 60px + padding-top 15px + padding-bottom 15px
   + border-bottom 2px ≈ 92px. Safe start offset: 90px.
   Mobile: compact single-row header ≈ 56px.                  */
:root {
  --site-topbar-height: 90px;
}

/* ── Absolute visibility guards (prevents any state conflict) */
.is-hidden,
[hidden],
#guestPanel.is-hidden,
#guestPanel[hidden],
#userPanel.is-hidden,
#userPanel[hidden] {
  display: none !important;
}

/* ── Header shell ────────────────────────────────────────── */
#siteTopbar > header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;

  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);

  border-bottom: 2px solid #ffd700;
  box-sizing: border-box;
}

/* ── Inner layout ────────────────────────────────────────── */
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 15px 5%;
  box-sizing: border-box;
}

/* ── Logo ────────────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo img {
  height: 60px;
  width: auto;
  object-fit: contain;
}

/* ── Topbar nav area (contains guest & user panels & menu) ── */
.topbar-nav-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Auth buttons (guest panel) ──────────────────────────── */
.auth-buttons-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-auth {
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.25s;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-auth:hover {
  transform: translateY(-2px);
}

.btn-login {
  background: #333;
  color: #fff;
}

.btn-register {
  background: linear-gradient(180deg, #ffd700, #ff8c00);
  color: #000;
}

.btn-topup {
  background: #00bcd4;
  color: #fff;
}

/* ── User panel (logged-in) ──────────────────────────────── */
.user-logged-info {
  display: none;        /* hidden by default; updateUI() in main.js sets display:flex */
  align-items: center;
  gap: 12px;
}

/* ── User chip (clickable -> opens profile & bet history) ── */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.user-chip:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 215, 0, 0.5);
  transform: translateY(-1px);
}

.user-chip .user-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.user-chip .user-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Balance chip ────────────────────────────────────────── */
.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.28);
  white-space: nowrap;
}

.balance-chip .balance-icon {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.balance-chip .wallet-balance {
  color: #00ff66;
  font-weight: 700;
  font-size: 14px;
}

.balance-chip .balance-unit {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 500;
}

/* ── Desktop-only elements & Mobile-only elements toggles ─── */
.desktop-only-btn {
  display: inline-flex;
}

.mobile-menu-wrapper {
  position: relative;
  display: none;
}

.btn-menu-toggle {
  display: none;
}

.user-dropdown-menu {
  display: none;
}

/* ============================================================
   MOBILE 1-ROW COMPACT RESPONSIVE (<= 768px)
   Strictly enforces 1 row:
   Logged out: [LOGO] [Đăng Nhập] [Đăng Ký] [☰]
   Logged in:  [LOGO] [👤 username] [💰 balance] [Nạp Tiền] [☰]
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --site-topbar-height: 56px;
  }

  #siteTopbar > header {
    height: 56px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
  }

  .header-inner {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 8px !important;
    gap: 6px !important;
    height: 56px !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Logo: auto-width, strictly 1 row, never wraps */
  .logo {
    width: auto !important;
    text-align: left !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  .logo a {
    display: flex !important;
    align-items: center !important;
  }

  .logo img {
    height: 30px !important;
    width: auto !important;
    max-width: 65px !important;
    object-fit: contain !important;
  }

  /* Topbar navigation area */
  .topbar-nav-area {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    gap: 5px !important;
  }

  /* Guest panel: compact 1-row layout (DO NOT use display: flex !important) */
  .auth-buttons-group {
    width: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 5px;
    justify-content: flex-end;
    align-items: center;
  }

  .auth-buttons-group .btn-auth {
    padding: 6px 9px !important;
    font-size: 11.5px !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
  }

  /* User panel: strictly single row, flex-wrap nowrap (DO NOT use display: flex !important) */
  .user-logged-info {
    width: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    min-width: 0;
  }

  /* Clickable User pill */
  .user-chip {
    padding: 4px 7px !important;
    gap: 3px !important;
    min-width: 0 !important;
    flex-shrink: 1 !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 14px !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .user-chip .user-icon {
    font-size: 12.5px !important;
    line-height: 1 !important;
  }

  .user-chip .user-name {
    font-size: 11.5px !important;
    max-width: 75px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    display: inline-block !important;
  }

  /* Balance pill */
  .balance-chip {
    padding: 4px 6px !important;
    gap: 3px !important;
    flex-shrink: 0 !important;
    background: rgba(255, 215, 0, 0.09) !important;
    border: 1px solid rgba(255, 215, 0, 0.3) !important;
    border-radius: 14px !important;
    white-space: nowrap !important;
  }

  .balance-chip .balance-icon {
    font-size: 12px !important;
    line-height: 1 !important;
  }

  .balance-chip .wallet-balance {
    font-size: 11.5px !important;
    color: #00ff66 !important;
    font-weight: 700 !important;
  }

  .balance-chip .balance-unit {
    font-size: 10.5px !important;
    color: rgba(255, 255, 255, 0.65) !important;
  }

  /* Nạp Tiền Button on mobile: compact, clear, clickable */
  .btn-topup {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 5px 8px !important;
    font-size: 11.5px !important;
    border-radius: 10px !important;
    background: linear-gradient(135deg, #00bcd4, #008ba3) !important;
    color: #fff !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(0, 188, 212, 0.35) !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    border: none !important;
    cursor: pointer !important;
  }

  .btn-topup:active {
    transform: scale(0.95) !important;
  }

  /* Hide Rút Tiền and Thoát desktop buttons on mobile (they are in menu ☰) */
  .desktop-only-btn {
    display: none !important;
  }

  /* Mobile menu wrapper & toggle button */
  .mobile-menu-wrapper {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
  }

  .btn-menu-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255, 215, 0, 0.4) !important;
    background: rgba(255, 215, 0, 0.12) !important;
    color: #ffd700 !important;
    font-size: 17px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    transition: background 0.18s, transform 0.15s, border-color 0.2s !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .btn-menu-toggle:active {
    transform: scale(0.93) !important;
    background: rgba(255, 215, 0, 0.25) !important;
  }

  /* Floating dropdown menu */
  .user-dropdown-menu {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 0 !important;
    width: 170px !important;
    background: #0f1522 !important;
    border: 1px solid rgba(255, 215, 0, 0.35) !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.9), 0 0 16px rgba(255, 215, 0, 0.15) !important;
    padding: 6px !important;
    display: none;
    flex-direction: column !important;
    gap: 4px !important;
    z-index: 10050 !important;
  }

  .user-dropdown-menu.show {
    display: flex !important;
    animation: topbarDropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes topbarDropdownFadeIn {
    from {
      opacity: 0;
      transform: translateY(-6px) scale(0.97);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  .menu-state-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
  }

  .user-dropdown-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 9px 12px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 8px !important;
    color: #e2e8f0 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-align: left !important;
    cursor: pointer !important;
    transition: background 0.15s, color 0.15s !important;
    box-sizing: border-box !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .user-dropdown-item:active,
  .user-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
  }

  .user-dropdown-item.item-topup:active,
  .user-dropdown-item.item-topup:hover {
    background: rgba(0, 188, 212, 0.18) !important;
    color: #22d3ee !important;
  }

  .user-dropdown-item.item-withdraw:active,
  .user-dropdown-item.item-withdraw:hover {
    background: rgba(233, 30, 99, 0.18) !important;
    color: #f472b6 !important;
  }

  .user-dropdown-item.item-profile:active,
  .user-dropdown-item.item-profile:hover {
    background: rgba(255, 215, 0, 0.18) !important;
    color: #ffd700 !important;
  }

  .user-dropdown-item.item-logout:active,
  .user-dropdown-item.item-logout:hover {
    background: rgba(239, 68, 68, 0.18) !important;
    color: #fca5a5 !important;
  }

  .dropdown-item-icon {
    font-size: 15px !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
  }

  .dropdown-item-text {
    flex: 1 1 auto !important;
  }
}

/* ============================================================
   EXTRA SMALL MOBILE SCREENS (<= 360px: e.g. 320px)
   Ultra compact fonts and paddings to guarantee 100% 1-row
   ============================================================ */
@media (max-width: 360px) {
  .header-inner {
    padding: 0 4px !important;
    gap: 3px !important;
  }

  .logo img {
    height: 24px !important;
    max-width: 50px !important;
  }

  .topbar-nav-area {
    gap: 3px !important;
  }

  .user-logged-info {
    gap: 3px !important;
  }

  .user-chip {
    padding: 3px 5px !important;
  }

  .user-chip .user-name {
    max-width: 55px !important;
    font-size: 10.5px !important;
  }

  .balance-chip {
    padding: 3px 5px !important;
  }

  .balance-chip .wallet-balance {
    font-size: 10.5px !important;
  }

  .balance-chip .balance-unit {
    display: none !important; /* Hide 'Điểm' on <= 360px to preserve space */
  }

  .btn-topup {
    padding: 4px 6px !important;
    font-size: 10.5px !important;
  }

  .btn-menu-toggle {
    width: 28px !important;
    height: 28px !important;
    font-size: 15px !important;
  }

  .auth-buttons-group .btn-auth {
    padding: 5px 7px !important;
    font-size: 10.5px !important;
  }
}
