/* ============================================================
   HEADER - Pixel-perfect match to design screenshots
   ============================================================ */

.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 500;
  height: var(--header-h);
  background: var(--clr-header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--clr-border);
  transition: background var(--transition);
}

.site-header.scrolled {
  background: var(--clr-header-bg-scrolled);
  box-shadow: var(--clr-header-shadow-scrolled);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--sp-8);
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Logo ── */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo .logo-icon {
  width: 36px;
  height: 36px;
}

.site-logo .logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.site-logo .logo-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--clr-white);
  letter-spacing: -0.5px;
}

.site-logo .logo-tag {
  font-size: 10px;
  color: var(--clr-text-dim);
  font-weight: 400;
}

.logo-drop {
  color: var(--clr-gold);
  font-size: 28px;
  margin-left: 4px;
}

/* ── Primary Navigation ── */
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin: 0 var(--sp-8);
}

.header-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px var(--sp-3);
  font-size: var(--font-size-sm);
  color: var(--clr-text-muted);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  white-space: nowrap;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--clr-white);
  background: var(--clr-nav-hover-bg);
}

.header-nav a svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.header-nav a:hover svg { opacity: 1; }

/* ── Header Actions ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

/* ── Dark Mode Toggle ── */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--clr-bg-input);
  border: 1px solid var(--clr-border);
  color: var(--clr-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--clr-gold); color: var(--clr-gold); }
.theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .theme-icon-sun  { display: block; }

/* ── Wishlist ── */
.header-wishlist {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--clr-bg-input);
  border: 1px solid var(--clr-border);
  color: var(--clr-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.header-wishlist:hover { border-color: #e74c7d; color: #e74c7d; }

/* ── User Menu ── */
.user-menu-wrap {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--clr-gold);
  color: #0d0f14;
  border-radius: var(--radius-md);
  padding: 7px var(--sp-3);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
}
.user-menu-trigger:hover { background: var(--clr-gold-dark); }
.user-menu-trigger svg   { width: 16px; height: 16px; }
.user-menu-trigger .chevron { width: 12px; height: 12px; transition: transform var(--transition); }
.user-menu-wrap.open .user-menu-trigger .chevron { transform: rotate(180deg); }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: all var(--transition);
  z-index: 600;
}
.user-menu-wrap.open .user-dropdown {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.user-dropdown a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--clr-text-muted);
  white-space: nowrap;
  transition: all var(--transition);
}
.user-dropdown a:hover {
  background: var(--clr-gold-bg);
  color: var(--clr-gold);
}
.user-dropdown a svg { width: 16px; height: 16px; }
.user-dropdown .divider { margin: var(--sp-1) 0; }
.user-dropdown a.danger:hover { background: var(--clr-red-bg); color: var(--clr-red); }

/* Small unread-count pill, used in both the desktop avatar dropdown and
 * the mobile drawer's "برنامه سرویس" link. */
.notif-badge {
  margin-right: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--clr-red);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Mobile Hamburger ── */
.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  border-radius: var(--radius-md);
  background: var(--clr-bg-input);
  border: 1px solid var(--clr-border);
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--clr-text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ── Mobile Menu ── */
/*
 * Single canonical definition. responsive.css previously re-declared
 * .mobile-menu with conflicting right/-100% technique inside @media(max-width:768px)
 * while header.css used transform. The two fought each other. Now header.css wins
 * with the slide-in drawer approach (right: -100% → right: 0) and responsive.css
 * overrides are removed.
 */
.mobile-menu {
  position: fixed;
  top: var(--header-h);
  right: -100%;          /* RTL: drawer enters from the right */
  width: min(280px, 88vw);
  height: calc(100vh - var(--header-h));
  background: var(--clr-bg-card);
  border-left: 1px solid var(--clr-border);
  z-index: 499;
  overflow-y: auto;
  transition: right var(--transition-slow), box-shadow var(--transition-slow);
  padding: var(--sp-5) var(--sp-3);
  display: none;         /* hidden on desktop */
}
.mobile-menu.open {
  right: 0;
  box-shadow: -8px 0 40px rgba(0,0,0,0.6);
}

/* Overlay — use body::before, bulletproof, no stacking context issues */
.mobile-menu-overlay {
  display: none; /* kept in DOM for JS click handler compatibility */
  pointer-events: none;
}

/* The REAL overlay is body::before — always works, no z-index fights */
body.menu-open::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  z-index: 496; /* below overlay div (498) and menu (499), above all content */
}
body.menu-open { overflow: hidden; }

.mobile-menu .nav-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.mobile-menu .nav-links a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px var(--sp-4);
  border-radius: var(--radius-md);
  color: var(--clr-text);
  font-size: var(--font-size-base);
  border: 1px solid var(--clr-border);
  transition: all var(--transition);
  white-space: nowrap;
}
.mobile-menu .nav-links a:hover,
.mobile-menu .nav-links a.active {
  border-color: var(--clr-gold);
  background: var(--clr-gold-bg);
  color: var(--clr-gold);
}

/* ── Page offset for fixed header ── */
body { padding-top: var(--header-h); }

/* ── WordPress Admin Bar: header sits BELOW wpadminbar ── */
/*
 * FIX: Previously only top was adjusted for admin-bar but body padding-top
 * was never updated, causing the header to overlap page content on desktop.
 * Now padding-top accounts for both header height + admin bar height.
 */
body.admin-bar .site-header {
  top: 32px;
}
/*body.admin-bar {*/
/*  padding-top: calc(var(--header-h) + 32px);*/
/*}*/
body.admin-bar .mobile-menu {
  top: calc(var(--header-h) + 32px);
  height: calc(100vh - var(--header-h) - 32px);
}
/* Mobile admin bar is 46px tall */
@media screen and (max-width: 782px) {
  body.admin-bar .site-header {
    top: 46px;
  }
  body.admin-bar {
    /*padding-top: calc(var(--header-h) + 46px);*/
  }
  body.admin-bar .mobile-menu {
    top: calc(var(--header-h) + 46px);
    height: calc(100vh - var(--header-h) - 46px);
  }
}

/* ── Responsive ── */
@media (max-width: 991px) {
  .header-nav { display: none; }
  .hamburger  { display: flex; }
  .mobile-menu { display: block; }   /* show the drawer container */
  .header-inner { padding: 0 var(--sp-4); }

  /* FIX: the avatar/user-dropdown menu was never hidden on mobile, so it
   * could be opened at the same time as the hamburger drawer with no
   * mutual exclusion between the two (see assets/js/main.js) - the
   * result was two overlapping menus fighting for the same screen space.
   * All of its links (dashboard, vehicles, maintenance, wishlist,
   * compare, logout) now live in .mobile-menu below, so on narrow
   * screens the hamburger drawer is the single nav entry point and the
   * avatar dropdown is fully hidden instead of colliding with it. */
  .user-menu-wrap { display: none; }
}

@media (min-width: 992px) {
  .hamburger       { display: none !important; }
  .mobile-menu     { display: none !important; }
  .mobile-menu-overlay { display: none !important; }
}

@media (max-width: 480px) {
  .header-actions { gap: var(--sp-2); }
  .theme-toggle, .header-wishlist { width: 32px; height: 32px; }
}


/* NOTE: global responsive hardening rules are in assets/css/responsive.css */
