/* ============================================================
   PHOENIX HEADER - Complete Redesign
   Professional SaaS Dashboard Style
   Inspired by: Vercel, Linear, Stripe, Notion, Figma
   ============================================================ */

/* ------------------------------------------------------------
   1) Reset & Base
   ------------------------------------------------------------ */
body {
  margin: 0;
  padding: 0;
}

body:has(.phx-header) .wrap {
  padding-top: 0;
}

/* حذف padding در صفحات landing و login - مهم است که قبل از media query ها باشد */
body:has(.landing-hero) .wrap,
body:has(.login-container) .wrap,
body:has(.login-container) .shell,
.landing-hero ~ .wrap,
.login-container ~ .wrap {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

/* حذف padding در صفحات login - با اولویت بالاتر */
body:has(.login-container) .wrap {
  padding: 0 !important;
  margin: 0 !important;
}

/* ------------------------------------------------------------
   2) Main Header Container
   ------------------------------------------------------------ */
.phx-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  margin: 0;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  min-height: 68px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.phx-header-inner {
  max-width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 68px;
  height: auto;
  padding: 0 24px;
}

/* ------------------------------------------------------------
   3) Header Left (Logo & Mobile Menu)
   ------------------------------------------------------------ */
.phx-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.phx-mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text, #1f2937);
  border-radius: 6px;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}

.phx-mobile-menu-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.phx-mobile-menu-btn:focus {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}

.phx-header-brand-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  margin-right: -12px;
  padding-right: 8px;
  padding-top: 10px;
  padding-bottom: 10px;
  border-right: 1px solid rgba(229, 231, 235, 0.8);
}

.phx-header-logo {
  display: flex;
  align-items: center;
}

.phx-header-brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #1b3c59;
  line-height: 1;
}

/* ------------------------------------------------------------
   3.1) Header Clock (ساعت و تاریخ)
   ------------------------------------------------------------ */
.phx-header-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  min-width: 160px;
  position: relative;
}

.phx-clock-time {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  direction: ltr;
  text-align: left;
  font-family: 'Vazirmatn', 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.phx-clock-date {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.01em;
  text-align: left;
}

/* Dark theme support */
html.theme-dark .phx-header-clock {
  border-right-color: rgba(255, 255, 255, 0.12);
}

html.theme-dark .phx-clock-time {
  background: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

html.theme-dark .phx-clock-date {
  color: #9ca3af;
}

/* Cool theme support */
html.theme-cool .phx-header-clock {
  border-right-color: rgba(14, 165, 233, 0.2);
}

html.theme-cool .phx-clock-time {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Responsive: hide clock on small/medium screens */
@media (max-width: 1024px) {
  .phx-header-clock {
    display: none;
  }
}

/* Animation for time updates */
.phx-clock-time {
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: contents;
}

.phx-clock-time.updating {
  opacity: 0.5;
}

/* ------------------------------------------------------------
   4) Header Center (Navigation)
   ------------------------------------------------------------ */
.phx-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  min-width: 0; /* برای اجازه دادن به shrink شدن */
}

.phx-main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.phx-nav-items {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap; /* اجازه wrap شدن در دو ردیف */
  justify-content: center;
  width: 100%;
}

.phx-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #1b3c59;
  text-decoration: none;
  border-radius: 6px;
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  height: 36px;
}

.phx-nav-link:hover {
  background: #f3f4f6;
}

.phx-nav-link.is-active {
  color: #1f6f5f;
  background: rgba(31, 111, 95, 0.08);
}

.phx-nav-link.is-active::after {
  content: '';
  position: absolute;
  bottom: 0;
  inset-inline-start: 14px;
  inset-inline-end: 14px;
  height: 2px;
  background: #1f6f5f;
  border-radius: 1px 1px 0 0;
}

/* استایل‌های مختلف برای لینک‌ها */
.phx-nav-link-default {
  color: #1b3c59;
}

.phx-nav-link-default:hover {
  color: #1b3c59;
  background: #f3f4f6;
}

.phx-nav-link-default.is-active {
  color: #1f6f5f;
  background: rgba(31, 111, 95, 0.08);
}

.phx-nav-link-default.is-active::after {
  background: #1f6f5f;
}

.phx-nav-link-manager {
  color: #1b3c59;
}

.phx-nav-link-manager:hover {
  color: #1f6f5f;
  background: #f0f4f6;
}

.phx-nav-link-manager.is-active {
  color: #1f6f5f;
  background: rgba(31, 111, 95, 0.08);
}

.phx-nav-link-manager.is-active::after {
  background: #1f6f5f;
}

.phx-nav-separator {
  width: 1px;
  height: 20px;
  background: #e5e7eb;
  margin: 0 8px;
  flex-shrink: 0;
  align-self: center;
}

/* در حالت دو ردیف، separator را مخفی می‌کنیم و از gap استفاده می‌کنیم */
@media (max-width: 1300px) {
  .phx-nav-separator {
    display: none;
  }
  
  /* اضافه کردن فاصله بیشتر بین گروه‌های آیتم‌ها */
  .phx-nav-items {
    gap: 6px;
  }
}

/* ------------------------------------------------------------
   5) Header Right (User Actions)
   ------------------------------------------------------------ */
.phx-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.phx-header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

.phx-header-username {
  font-size: 14px;
  font-weight: 500;
  color: #1b3c59;
}

.phx-header-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #e5e7eb;
  color: #1b3c59;
}

.phx-header-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.phx-header-logout:hover {
  background: #fef2f2;
  color: #d9534f;
  border-color: #f3d2cf;
}

.phx-header-logout:focus {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   6) Mobile Drawer
   ------------------------------------------------------------ */
.phx-mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  visibility: hidden;
  will-change: opacity;
}

.phx-mobile-drawer-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Hide drawer and overlay on desktop by default */
.phx-mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  width: 10%;
  min-width: 180px;
  max-width: 220px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  direction: ltr;
  will-change: transform, opacity;
  display: none;
}

.phx-mobile-drawer.is-active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.phx-mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
  padding: 12px 16px 12px 0 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 10;
  direction: ltr;
}

.phx-mobile-drawer-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text, #1f2937);
  margin: 0;
  margin-right: 0;
  margin-left: auto;
  text-align: right;
  direction: ltr;
}

.phx-mobile-drawer-close {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text, #1f2937);
  transition: background-color 0.15s ease;
  padding: 0;
}

.phx-mobile-drawer-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ساعت و تاریخ در منوی موبایل - استایل رسمی و حرفه‌ای */
.phx-mobile-drawer-clock {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #ffffff;
  direction: rtl;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.phx-mobile-clock-time {
  font-size: 22px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  font-family: 'Vazirmatn', 'Courier New', monospace;
  letter-spacing: 1.5px;
  line-height: 1.4;
  padding: 0;
  display: block;
}

.phx-mobile-clock-date {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0;
  padding: 0;
  display: block;
}

.phx-mobile-drawer-content {
  padding: 8px 0 8px 0 !important;
  direction: ltr;
  text-align: right;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s,
              transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s;
}

.phx-mobile-drawer.is-active .phx-mobile-drawer-content {
  opacity: 1;
  transform: translateX(0);
}

.phx-mobile-drawer-content .phx-nav-items {
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  direction: ltr;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}

.phx-mobile-drawer-content .phx-nav-link {
  width: 100% !important;
  justify-content: flex-end !important;
  padding: 10px 16px 10px 0 !important;
  padding-left: 0 !important;
  padding-right: 16px !important;
  height: auto !important;
  border-radius: 0 !important;
  border-right: 3px solid transparent;
  text-align: right !important;
  direction: ltr !important;
  display: flex !important;
  align-items: center !important;
  margin: 0 !important;
  white-space: normal !important;
}

.phx-mobile-drawer-content .phx-nav-link-default {
  color: var(--text, #1f2937);
}

.phx-mobile-drawer-content .phx-nav-link-default.is-active {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  border-right-color: #ef4444;
}

.phx-mobile-drawer-content .phx-nav-link-manager {
  color: #3b82f6;
}

.phx-mobile-drawer-content .phx-nav-link-manager.is-active {
  background: rgba(59, 130, 246, 0.12);
  border-right-color: #3b82f6;
}

.phx-mobile-drawer-content .phx-nav-link.is-active::after {
  display: none;
}

.phx-mobile-drawer-content .phx-nav-separator,
.phx-mobile-drawer-content .phx-mobile-nav-separator {
  width: 100% !important;
  height: 2px !important;
  margin: 16px 0 !important;
  padding: 0 !important;
  background: linear-gradient(to left, 
    rgba(0, 0, 0, 0.3) 0%, 
    rgba(0, 0, 0, 0.2) 50%, 
    rgba(0, 0, 0, 0.3) 100%) !important;
  border-radius: 1px !important;
  display: block !important;
  flex-basis: 100% !important;
  flex-grow: 1 !important;
  flex-shrink: 0 !important;
  order: 999 !important; /* separator را بعد از آیتم‌های عادی قرار می‌دهد */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  align-self: stretch !important;
}

.phx-mobile-drawer-content .phx-mobile-logout-separator {
  width: auto !important;
  height: 1px !important;
  margin: 8px 16px 8px 0 !important;
  background: rgba(0, 0, 0, 0.12) !important;
}

.phx-mobile-drawer-content .phx-nav-link-logout {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 10px 16px 10px 0 !important;
  width: 100% !important;
  justify-content: flex-end !important;
  border-radius: 0 !important;
  border-right: 3px solid transparent !important;
  margin: 0 !important;
  margin-top: 8px !important;
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.08) !important;
  text-decoration: none !important;
}

.phx-mobile-drawer-content .phx-nav-link-logout:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #dc2626 !important;
  border-right-color: #ef4444 !important;
}

.phx-mobile-drawer-content .phx-nav-link-logout svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.phx-mobile-drawer-content .phx-logout-text {
  margin-right: 8px;
}

/* ------------------------------------------------------------
   7) Theme Compatibility
   ------------------------------------------------------------ */

/* Light Theme (Default) */
.phx-header {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 2px 6px rgba(0, 0, 0, 0.03);
}

/* Dark Theme */
html.theme-dark .phx-header {
  background: #0f172a;
  border-bottom-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.2);
}

html.theme-dark .phx-header-brand {
  color: #f8fafc;
}

html.theme-dark .phx-nav-link {
  color: #e5e7eb;
}

html.theme-dark .phx-nav-link-default {
  color: #e5e7eb;
}

html.theme-dark .phx-nav-link-default:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06);
}

html.theme-dark .phx-nav-link-default.is-active {
  color: #f87171;
  background: rgba(239, 68, 68, 0.2);
}

html.theme-dark .phx-nav-link-manager {
  color: #60a5fa;
}

html.theme-dark .phx-nav-link-manager:hover {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
}

html.theme-dark .phx-nav-link-manager.is-active {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.2);
}

html.theme-dark .phx-nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

html.theme-dark .phx-nav-separator {
  background: rgba(255, 255, 255, 0.15);
}

html.theme-dark .phx-header-user {
  background: rgba(255, 255, 255, 0.05);
}

html.theme-dark .phx-header-username {
  color: #e5e7eb;
}

html.theme-dark .phx-header-badge {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

html.theme-dark .phx-header-logout {
  color: #e5e7eb;
}

html.theme-dark .phx-mobile-drawer {
  background: #1e293b;
}

html.theme-dark .phx-mobile-drawer-header {
  background: #1e293b;
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

html.theme-dark .phx-mobile-drawer-title {
  color: #f8fafc;
}

html.theme-dark .phx-mobile-drawer-close {
  color: #e5e7eb;
}

html.theme-dark .phx-mobile-drawer-content .phx-nav-link-logout {
  color: #f87171 !important;
  background: rgba(239, 68, 68, 0.15) !important;
}

html.theme-dark .phx-mobile-drawer-content .phx-nav-link-logout:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  color: #fca5a5 !important;
  border-right-color: #ef4444 !important;
}

html.theme-dark .phx-mobile-drawer-content .phx-mobile-logout-separator {
  background: rgba(255, 255, 255, 0.15) !important;
}

html.theme-dark .phx-mobile-drawer-content .phx-nav-separator {
  background: linear-gradient(to left, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.25)) !important;
}

/* Dark theme برای ساعت و تاریخ در منوی موبایل */
html.theme-dark .phx-mobile-drawer-clock {
  background: #1e293b;
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

html.theme-dark .phx-mobile-clock-time {
  color: #f1f5f9;
}

html.theme-dark .phx-mobile-clock-date {
  color: #94a3b8;
}

/* Cool Theme */
html.theme-cool .phx-header {
  background: #ffffff;
  border-bottom-color: rgba(14, 165, 233, 0.15);
  box-shadow: 0 1px 3px rgba(14, 165, 233, 0.08), 0 2px 6px rgba(14, 165, 233, 0.05);
}

html.theme-cool .phx-nav-link-default {
  color: var(--text, #082f49);
}

html.theme-cool .phx-nav-link-default.is-active {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

html.theme-cool .phx-nav-link-default.is-active::after {
  background: #ef4444;
}

html.theme-cool .phx-nav-link-manager {
  color: #3b82f6;
}

html.theme-cool .phx-nav-link-manager.is-active {
  color: #0ea5e9;
  background: rgba(14, 165, 233, 0.12);
}

html.theme-cool .phx-nav-link-manager.is-active::after {
  background: #0ea5e9;
}

/* ------------------------------------------------------------
   8) Mobile Responsiveness
   ------------------------------------------------------------ */

/* در عرض‌های متوسط، نوبار را در دو ردیف نمایش می‌دهیم */
@media (max-width: 1300px) {
  .phx-header-inner {
    gap: 16px;
    padding: 10px 20px;
    align-items: flex-start;
    min-height: 68px;
  }
  
  .phx-header {
    min-height: auto;
  }
  
  .phx-header-center {
    align-items: flex-start;
    padding-top: 2px;
    min-height: 48px; /* حداقل ارتفاع برای دو ردیف */
  }
  
  .phx-nav-items {
    flex-wrap: wrap;
    gap: 4px;
    row-gap: 4px;
    max-width: 100%;
  }
  
  .phx-nav-link {
    padding: 6px 12px;
    font-size: 12px;
    height: 32px;
    flex-shrink: 0;
    min-width: fit-content;
  }
  
  .phx-header-left,
  .phx-header-right {
    align-self: center;
    flex-shrink: 0;
  }
}

/* در عرض‌های کوچک‌تر، دکمه منوی موبایل را نمایش می‌دهیم */
@media (max-width: 900px), (max-device-width: 900px) {
  .phx-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1000 !important;
    min-height: 68px;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  .phx-header-inner {
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    padding: 8px 16px;
    min-height: 68px;
    height: 68px;
  }
  
  .phx-mobile-menu-btn {
    display: flex;
  }
  
  .phx-header-center {
    display: none;
  }
  
  /* اضافه کردن padding-top به body برای جلوگیری از پوشیده شدن محتوا - فقط وقتی navbar وجود دارد و landing/login نیست */
  body:has(.phx-header):not(:has(.landing-hero)):not(:has(.login-container)) .wrap {
    padding-top: 68px !important;
  }
  
  /* Fallback برای مرورگرهایی که :has() را پشتیبانی نمی‌کنند */
  body:not(:has(.landing-hero)):not(:has(.login-container)) .phx-header ~ * .wrap {
    padding-top: 68px !important;
  }
  
  /* حذف padding در صفحات landing و login - با اولویت بالا */
  body:has(.landing-hero) .wrap,
  body:has(.login-container) .wrap,
  .landing-hero ~ .wrap,
  .login-container ~ .wrap {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
}

@media (max-width: 500px), (max-device-width: 500px) {
  .phx-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1000 !important;
    height: 56px;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  .phx-header-inner {
    height: 56px;
    padding: 0 12px;
    gap: 8px;
  }
  
  /* اضافه کردن padding-top به body برای جلوگیری از پوشیده شدن محتوا - فقط وقتی navbar وجود دارد و landing/login نیست */
  body:has(.phx-header):not(:has(.landing-hero)):not(:has(.login-container)) .wrap {
    padding-top: 56px !important;
  }
  
  /* Fallback برای مرورگرهایی که :has() را پشتیبانی نمی‌کنند */
  body:not(:has(.landing-hero)):not(:has(.login-container)) .phx-header ~ * .wrap {
    padding-top: 56px !important;
  }
  
  /* حذف padding در صفحات landing و login - با اولویت بالا */
  body:has(.landing-hero) .wrap,
  body:has(.login-container) .wrap,
  .landing-hero ~ .wrap,
  .login-container ~ .wrap {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  
  .phx-mobile-menu-btn {
    display: flex;
  }
  
  .phx-header-brand {
    font-size: 16px;
  }
  
  .phx-header-user {
    display: flex;
    gap: 6px;
    padding: 4px 8px;
  }
  
  .phx-header-username {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
  }
  
  .phx-header-badge {
    font-size: 10px;
    padding: 1px 6px;
  }
  
  .phx-header-logout {
    width: 32px;
    height: 32px;
  }
  
  /* نمایش overlay و drawer فقط در موبایل - اما فقط وقتی فعال هستند */
  /* در حالت عادی، overlay و drawer باید کاملاً مخفی باشند */
  /* در موبایل، فقط وقتی فعال است نمایش داده شود */
  /* Show drawer and overlay in mobile, use visibility/opacity for animation */
  .phx-mobile-drawer-overlay {
    display: block !important;
  }
  
  .phx-mobile-drawer-overlay:not(.is-active) {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  
  .phx-mobile-drawer-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }
  
  .phx-mobile-drawer {
    display: block !important;
  }
  
  .phx-mobile-drawer:not(.is-active) {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateX(100%) !important;
  }
  
  .phx-mobile-drawer.is-active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }
  
}

/* ------------------------------------------------------------
   9) Body Scroll Lock
   ------------------------------------------------------------ */
body.phx-drawer-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
}
