/* ================================
   Navbar: Phượng Hoàng V2
   Top Bar, Header, Mobile Menu,
   Language Switcher, Theme Switcher
   JS: menu.js, phong.js
   ================================ */

/* ═══════════ TOP BAR ═══════════
   In document flow above the fixed header.
   Owns the brand identity at every breakpoint:
   brand + tagline left, contacts + social right.
   Same box model as .container-wide / .header-inner (0 edge drift). */
.top-bar {
  height: var(--ph-topbar-h);
  border-bottom: var(--ph-border-width-thin) solid var(--ph-divider);
  font: var(--ph-text-caption);
}

.top-bar-inner {
  max-width: var(--ph-container-wide);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--ph-space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ph-space-md);
  padding-top: 10px; /* 10px top padding keeps the bar from looking too tight on desktop */
  padding-bottom: 10px; /* 10px bottom padding: mirrors the top so the bar breathes evenly on both sides */
}

@media (max-width: 767px) {
  .top-bar-inner { padding: 0 var(--ph-space-sm); }
  .top-bar-contact { gap: var(--ph-space-2xs); }
  .top-bar-brand { gap: .5rem; }
  .top-bar-brand-logo { height: 1.625rem; } /* 26px tablet */
}

/* Tight phones: less inner gap so brand + hotline always fit on one row */
@media (max-width: 479px) {
  .top-bar-inner { gap: var(--ph-space-2xs); }
}

/* ── Brand lockup: logo + two stacked lines = one identity cluster.
   Logo sits BEFORE the text, centered on the 2-line block's height. ── */
.top-bar-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .625rem;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 0;
}
.top-bar-brand-logo {
  height: 1.875rem; /* 30px desktop, spec 28-34 */
  width: auto;
  flex-shrink: 0;
  display: block;
}
.top-bar-brand-texts {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  line-height: 1.25;
}

.top-bar-brand-text {
  font-size: 0.875rem;
  font-weight: 700;
  /* All-caps enterprise brand: a touch more tracking keeps it airy and
     legible without adding height or pushing the contact cluster. */
  letter-spacing: 0.02em;
  color: var(--ph-text-primary);
  white-space: nowrap;
}

.top-bar-tagline {
  display: none;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ph-text-muted);
  white-space: nowrap;
  /* Nới nhẹ chữ cho thoáng, CHỈ tagline, không đụng dòng brand phía trên.
     letter-spacing không đổi line box => khối 2 dòng giữ nguyên chiều cao,
     title .top-bar-brand-text không dịch chuyển dù chỉ một pixel. */
  letter-spacing: 0.03em;
}

/* Second line from desktop up; below that the brand line alone
   keeps the bar compact (contacts take the right side) */
@media (min-width: 1024px) {
  .top-bar-tagline { display: block; }
}

/* ── Contact links: Hotline + Hotline 2 + Email ── */
.top-bar-contact {
  display: flex;
  align-items: center;
  gap: var(--ph-space-xs);
  flex-shrink: 0;
}

.top-bar-contact-link {
  display: inline-flex;
  align-items: center;
  gap: var(--ph-space-2xs);
  color: var(--ph-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: color 200ms var(--ph-ease-out);
}

.top-bar-contact-link:hover {
  color: var(--ph-accent);
}

.top-bar-contact-label {
  color: var(--ph-text-muted);
}

.top-bar-icon {
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 200ms var(--ph-ease-out);
}

.top-bar-contact-link:hover .top-bar-icon {
  opacity: 1;
}

/* Contact labels are a desktop nicety; below desktop, bare numbers
   keep the bar from overflowing at tablet widths (768-1023) */
@media (max-width: 1023px) {
  .top-bar-contact-label { display: none; }
}

/* Tablet/phones: the longer all-caps brand scales down and ellipsizes
   rather than ever squeezing the contact cluster or overflowing.
   Desktop keeps the full name at full size. */
@media (max-width: 767px) {
  .top-bar-brand { flex-shrink: 1; }
  .top-bar-brand-texts { overflow: hidden; }
  .top-bar-brand-text {
    font-size: .8125rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Phones: second hotline + its pipe hide; brand text shrinks and
   ellipsizes rather than ever causing horizontal overflow */
@media (max-width: 479px) {
  .top-bar-contact-phone2 { display: none; }
  .top-bar-brand { gap: .5rem; flex-shrink: 1; }
  .top-bar-brand-logo { height: 1.5rem; } /* 24px */
  .top-bar-brand-text { font-size: .75rem; overflow: hidden; text-overflow: ellipsis; }
}

/* Email from desktop up; hotlines always visible (tap-to-call).
   At 768-1023 the contact cluster (2 hotlines + email) measures ~452px
   and overflows the top bar by 22px at 768 (audit: top-bar-contact
   L338 R790). Email joins the other desktop-only niceties (labels,
   social, tagline) at >= 1024. */
.top-bar-contact-email {
  display: none;
}

@media (min-width: 1024px) {
  .top-bar-contact-email { display: inline-flex; }
}

/* ── Thin separators: email group from desktop, social from desktop ── */
.top-bar-sep {
  width: 1px;
  height: 12px;
  background: var(--ph-border-hover);
  flex-shrink: 0;
}

.top-bar-sep-email { display: none; }
@media (min-width: 1024px) {
  .top-bar-sep-email { display: block; }
}

.top-bar-sep-social { display: none; }
@media (min-width: 1024px) {
  .top-bar-sep-social { display: block; }
}

/* ── Social icons: Facebook · TikTok · YouTube ── */
.top-bar-social {
  display: none;
  align-items: center;
  gap: 0.625rem;
}

@media (min-width: 1024px) {
  .top-bar-social { display: flex; }
}

.top-bar-social-link {
  display: inline-flex;
  align-items: center;
  color: var(--ph-text-secondary);
  opacity: 0.85;
  transition: color 200ms var(--ph-ease-out),
              opacity 200ms var(--ph-ease-out);
}

.top-bar-social-link:hover {
  color: var(--ph-accent);
  opacity: 1;
}

/* ── Header ── */
.site-header {
  position: fixed;
  top: var(--ph-topbar-h);
  left: 0;
  width: 100%;
  z-index: var(--ph-z-sticky);
  height: 68px;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background 350ms var(--ph-ease-out),
              border-color 350ms var(--ph-ease-out),
              height 350ms var(--ph-ease-out),
              top 350ms var(--ph-ease-out);
}

.site-header.scrolled {
  top: 0;
  background: rgba(11, 25, 41, 0.90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-color: var(--ph-divider);
  height: 60px;
}

[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: rgba(8, 51, 90, 0.05);
}

[data-theme="light"] .site-header.scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-color: rgba(8, 51, 90, 0.08);
  box-shadow: 0 1px 3px rgba(8, 51, 90, 0.04);
}

.header-inner {
  max-width: var(--ph-container-wide);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--ph-space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ph-space-lg);
}

@media (max-width: 767px) {
  .header-inner { padding: 0 var(--ph-space-sm); }
}

/* ── No logo here: the top bar owns the brand identity ──
   The header is a clean toolbar - navigation + actions only. */

/* ── Desktop Nav Links ── */
.navbar-links {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2.5vw, 36px);
  flex: 1;
  justify-content: flex-start;
}

@media (max-width: 1023px) {
  .navbar-links { display: none; }
}

.nav-link {
  color: var(--ph-text-secondary);
  text-decoration: none;
  /* +15% vs 0.8125rem base: roomier, still clearly navigation */
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: transparent;
  border: none;
  padding: 8px 0;
  cursor: pointer;
  transition: color 200ms var(--ph-ease-out);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1.5px;
  background: var(--ph-accent);
  border-radius: 1px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 250ms var(--ph-ease-out);
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

.nav-link:hover {
  color: var(--ph-accent);
}

.nav-link.active {
  color: var(--ph-accent);
}

/* ── Nav dropdown ("Sản phẩm") ──
   Pure CSS hover + focus-within. The trigger stays a REAL link:
   clicking "Sản phẩm" navigates straight to products.html with no
   delay and no forced menu choice. The dropdown is a child of the
   wrapper, so there is no hover gap - moving the pointer from the
   link onto the panel keeps it open. Hidden below 1024px together
   with .navbar-links (tablet/mobile use the hamburger submenu). */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
}
.nav-caret {
  display: inline-block;
  margin-left: 5px;
  font-size: .625rem;
  line-height: 1;
  color: var(--ph-text-muted);
  transition: transform var(--ph-duration-fast) var(--ph-ease-out);
}
.nav-item:hover .nav-caret,
.nav-item:focus-within .nav-caret {
  transform: rotate(180deg);
}
.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 15rem;
  padding: .375rem;
  display: flex;
  flex-direction: column;
  gap: .125rem;
  background: var(--ph-bg-primary);
  border: 1px solid var(--ph-divider);
  border-radius: var(--ph-radius-sm);
  box-shadow: var(--ph-shadow-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity var(--ph-duration-fast) var(--ph-ease-out),
              transform var(--ph-duration-fast) var(--ph-ease-out),
              visibility var(--ph-duration-fast);
}
.nav-item:hover .nav-dropdown,
.nav-item:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nav-dropdown-link {
  display: block;
  min-height: 44px;
  padding: .55rem .75rem;
  border-radius: calc(var(--ph-radius-sm) - .125rem);
  font-size: .875rem;
  font-weight: 500;
  color: var(--ph-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--ph-duration-fast) var(--ph-ease-out),
              background var(--ph-duration-fast) var(--ph-ease-out);
}
.nav-dropdown-link:hover,
.nav-dropdown-link:focus-visible {
  color: var(--ph-accent);
  background: var(--ph-accent-subtle);
}

/* ── Header Actions ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--ph-space-sm);
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Language Switcher ── */
.lang-switcher {
  display: flex;
  gap: 4px;
}

.lang-btn {
  height: 32px;
  padding: 0 var(--ph-space-xs);
  font: var(--ph-text-button-sm);
  background: transparent;
  border: var(--ph-border-width-thin) solid var(--ph-border-default);
  border-radius: var(--ph-radius-sm);
  color: var(--ph-text-muted);
  cursor: pointer;
  transition: all var(--ph-duration-fast) var(--ph-ease-out);
}

.lang-btn:hover {
  border-color: var(--ph-border-hover);
  color: var(--ph-text-secondary);
}

.lang-btn.active {
  background: var(--ph-accent);
  border-color: var(--ph-accent);
  color: var(--ph-text-inverse);
}

/* ── Theme Switcher ── */
.theme-switcher {
  display: flex;
  align-items: center;
}

.theme-toggle-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: var(--ph-border-width-thin) solid var(--ph-border-default);
  border-radius: var(--ph-radius-sm);
  color: var(--ph-text-secondary);
  cursor: pointer;
  font-size: 20px;
  transition: all var(--ph-duration-fast) var(--ph-ease-out);
}

.theme-toggle-btn:hover {
  border-color: var(--ph-border-hover);
  color: var(--ph-accent);
}

/* Icon swap: each theme shows the icon of the theme you can switch TO */
.theme-toggle-btn .icon-sun { display: block; }
.theme-toggle-btn .icon-moon { display: none; }
[data-theme="light"] .theme-toggle-btn .icon-sun { display: none; }
[data-theme="light"] .theme-toggle-btn .icon-moon { display: block; }

/* Compact tier 1024-1279px: keeps nav + actions on one line without overflow.
   MUST stay AFTER the base rules it overrides (same specificity ->
   source order decides the cascade). */
@media (min-width: 1024px) and (max-width: 1279px) {
  .navbar-links { gap: 8px; }
  .nav-link { font-size: 0.8125rem; }
  .header-inner { gap: 1.5rem; }
  .lang-btn { padding: 0 0.5rem; }
}

/* ── Mobile Menu Toggle ── */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: var(--ph-border-width-thin) solid var(--ph-border-default);
  border-radius: var(--ph-radius-sm);
  color: var(--ph-text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 8px 12px;
  line-height: 1;
  transition: all var(--ph-duration-fast) var(--ph-ease-out);
  flex-shrink: 0;
}

@media (max-width: 1023px) {
  .mobile-menu-toggle { display: flex; }
  .lang-switcher { display: none; }
}

.mobile-menu-toggle:hover {
  border-color: var(--ph-accent);
  color: var(--ph-accent);
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  transition: background 150ms var(--ph-ease-out);
}
.hamburger-line::before,
.hamburger-line::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 250ms var(--ph-ease-out);
}
.hamburger-line::before { top: -6px; }
.hamburger-line::after  { top: 6px; }

/* ── Mobile Menu Overlay ── */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--ph-z-overlay);
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ph-duration-normal) var(--ph-ease-out),
              visibility var(--ph-duration-normal);
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Mobile Menu Panel ── */
.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 85vw;
  height: 100%;
  z-index: var(--ph-z-modal);
  background: var(--ph-bg-primary);
  border-left: var(--ph-border-width-thin) solid var(--ph-divider);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.35s var(--ph-ease-out);
  padding: var(--ph-space-md);
}

.mobile-menu.active {
  transform: translateX(0);
}

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ph-space-md);
  padding-bottom: var(--ph-space-sm);
  border-bottom: var(--ph-border-width-thin) solid var(--ph-divider);
}

.mobile-menu-close {
  background: none;
  border: var(--ph-border-width-thin) solid var(--ph-border-default);
  border-radius: var(--ph-radius-sm);
  color: var(--ph-text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 6px 10px;
  line-height: 1;
  transition: all var(--ph-duration-fast) var(--ph-ease-out);
  min-width: 44px;
  min-height: 44px;
}

.mobile-menu-close:hover {
  border-color: var(--ph-accent);
  color: var(--ph-accent);
}

.mobile-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: var(--ph-space-sm);
  padding: 14px var(--ph-space-md);
  border-radius: var(--ph-radius-md);
  color: var(--ph-text-secondary);
  text-decoration: none;
  font: var(--ph-text-body);
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: all 150ms var(--ph-ease-out);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
  background: var(--ph-accent-subtle);
  color: var(--ph-accent);
}

.mobile-nav-link .arrow {
  margin-left: auto;
  font-size: 12px;
  transition: transform 250ms var(--ph-ease-out);
  opacity: 0.5;
}

.mobile-nav-link .arrow.open {
  transform: rotate(180deg);
  opacity: 1;
}

.mobile-submenu {
  display: none;
  padding: var(--ph-space-3xs) 0 var(--ph-space-3xs) var(--ph-space-md);
  flex-direction: column;
  gap: 2px;
}

.mobile-submenu.open {
  display: flex;
}

.mobile-sub-link {
  display: flex;
  align-items: center;
  gap: var(--ph-space-sm);
  padding: 10px var(--ph-space-md);
  border-radius: var(--ph-radius-md);
  color: var(--ph-text-secondary);
  text-decoration: none;
  font: var(--ph-text-body-sm);
  font-weight: 500;
  transition: all 150ms var(--ph-ease-out);
  position: relative;
  min-height: 44px;
}

.mobile-sub-link::before {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ph-text-muted);
  flex-shrink: 0;
  opacity: 0.4;
  transition: background 150ms var(--ph-ease-out),
              opacity 150ms var(--ph-ease-out);
}

.mobile-sub-link:hover {
  background: var(--ph-accent-subtle);
  color: var(--ph-accent);
}

.mobile-sub-link:hover::before {
  background: var(--ph-accent);
  opacity: 1;
}

.mobile-lang {
  margin-top: var(--ph-space-md);
  padding-top: var(--ph-space-sm);
  border-top: var(--ph-border-width-thin) solid var(--ph-divider);
  display: flex;
  gap: var(--ph-space-2xs);
  flex-wrap: wrap;
}

.mobile-lang .lang-btn {
  flex: 1;
  text-align: center;
  justify-content: center;
  height: 44px;
}

/* ── Responsive: Mobile header height ── */
@media (max-width: 479px) {
  .site-header {
    height: 58px;
  }
  .site-header.scrolled {
    height: 52px;
  }
}
