/* File: src/css/nav-user-menu.css */
/* Enhanced navigation with user menu and smart positioning */

/* ========================================
   All base nav.css styles included here
   ======================================== */

/* Base styles from nav.css... */
.navbar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}

.nav-brand {
  color: white;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.2s;
  z-index: 1001;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
}

.nav-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.nav-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.3s ease;
  opacity: 0.8;
}

.nav-item.active > .nav-toggle-submenu .nav-arrow {
  transform: rotate(-180deg);
}

/* ========================================
   USER MENU STYLES
   ======================================== */

/* User menu container */
.nav-user-menu {
  margin-left: auto; /* Push to right side */
}

/* User toggle button */
.nav-user-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.nav-user-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.nav-user-toggle .nav-label {
  font-weight: 600;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User photo */
.nav-user-photo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

/* Placeholder for missing photo */
.nav-user-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
}

/* User submenu */
.nav-user-submenu {
  min-width: 200px;
}

/* ========================================
   DIVIDER
   ======================================== */
.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0.25rem 0;
}

/* ========================================
   LOGOUT BUTTON (as menu item)
   ======================================== */
.nav-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.nav-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ========================================
   SUBMENUS - Base Styles
   ======================================== */
.nav-submenu {
  display: none !important;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-item.active > .nav-submenu {
  display: block !important;
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* ========================================
   SMART POSITIONING - Auto-flip on edges
   ======================================== */

/* Desktop positioning */
@media (min-width: 769px) {
  /* Ensure menu is always visible on desktop */
  .nav-menu {
    display: flex !important;
    gap: 0.25rem;
  }
  
  /* Hide mobile toggle on desktop */
  .nav-toggle {
    display: none !important;
  }
  
  .nav-link {
    padding: 0.5rem 0.75rem;
    width: auto;
  }
  
  /* Default: Dropdown appears below, aligned left */
  .nav-submenu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: auto !important;
    min-width: 240px !important;
    margin-top: 0.5rem !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    z-index: 100 !important;
  }
  
  /* SMART POSITIONING: Flip to right if near right edge */
  .nav-item.flip-right > .nav-submenu {
    left: auto !important;
    right: 0 !important;
  }
  
  /* User menu always aligns to right */
  .nav-user-menu > .nav-submenu {
    left: auto !important;
    right: 0 !important;
  }
  
  /* Nested submenus: Default flies out to right */
  .nav-submenu .nav-submenu {
    position: absolute !important;
    top: -1px !important;
    left: 100% !important;
    right: auto !important;
    margin-top: 0 !important;
    margin-left: 0.5rem !important;
    min-width: 220px !important;
  }
  
  /* SMART POSITIONING: Nested submenu flips left if near right edge */
  .nav-submenu .nav-item.flip-left > .nav-submenu {
    left: auto !important;
    right: 100% !important;
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
  }
  
  /* Arrow direction adjustments */
  .nav-submenu .nav-arrow {
    transform: rotate(-90deg); /* Point right */
  }
  
  .nav-submenu .nav-item.flip-left > .nav-toggle-submenu .nav-arrow {
    transform: rotate(90deg); /* Point left when flipped */
  }
  
  .nav-submenu .nav-link {
    padding: 0.75rem 1rem;
    width: 100%;
  }
  
  /* Bridge areas for easier mouse movement */
  .nav-item.has-submenu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.5rem;
    z-index: 99;
  }
  
  .nav-submenu .nav-item.has-submenu::after {
    content: '';
    position: absolute;
    top: 0;
    left: 100%;
    width: 0.5rem;
    height: 100%;
    z-index: 99;
  }
  
  /* Bridge for left-flipped nested menus */
  .nav-submenu .nav-item.flip-left.has-submenu::after {
    left: auto;
    right: 100%;
  }
  
  /* Ensure parent doesn't clip children */
  .nav-item,
  .nav-submenu {
    overflow: visible !important;
  }
  
  /* Proper stacking */
  .nav-item.active {
    position: relative;
    z-index: 101;
  }
}

/* ========================================
   Mobile Toggle - Hidden by default (desktop)
   ======================================== */
.nav-toggle {
  display: none; /* Hidden on desktop */
}

/* ========================================
   Mobile Styles
   ======================================== */
@media (max-width: 768px) {
  .nav-toggle {
    display: block; /* Show on mobile */
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
  }
  
  .nav-toggle-icon {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    position: relative;
    transition: background 0.3s;
  }
  
  .nav-toggle-icon::before,
  .nav-toggle-icon::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: white;
    transition: transform 0.3s;
  }
  
  .nav-toggle-icon::before {
    top: -8px;
  }
  
  .nav-toggle-icon::after {
    bottom: -8px;
  }
  
  .nav-toggle.active .nav-toggle-icon {
    background: transparent;
  }
  
  .nav-toggle.active .nav-toggle-icon::before {
    transform: rotate(45deg);
    top: 0;
  }
  
  .nav-toggle.active .nav-toggle-icon::after {
    transform: rotate(-45deg);
    bottom: 0;
  }
  
  .nav-menu {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
  }
  
  .nav-menu.active {
    max-height: calc(100vh - 60px);
    opacity: 1;
    overflow-y: auto;
  }
  
  .nav-user-menu {
    margin-left: 0;
    order: 999; /* Move to bottom on mobile */
  }
  
  .nav-link {
    padding: 0.75rem 1.5rem;
    border-radius: 0;
  }
  
  .nav-submenu {
    background: rgba(0, 0, 0, 0.15) !important;
    position: static !important;
    padding: 0;
    margin-top: 0;
    border-radius: 0;
  }
  
  .nav-submenu .nav-link {
    padding-left: 2.5rem;
    font-size: 0.9rem;
  }
  
  .nav-submenu .nav-submenu .nav-link {
    padding-left: 3.5rem;
  }
  
  .nav-divider {
    margin: 0.5rem 1rem;
  }
}

/* ========================================
   Accessibility
   ======================================== */
.nav-link:focus,
.nav-btn:focus,
.nav-toggle:focus {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

/* ========================================
   Animations
   ======================================== */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 769px) {
  .nav-item.active > .nav-submenu {
    animation: slideDown 0.2s ease-out;
  }
}

/* ========================================
   RTL Support (for Hebrew)
   ======================================== */
@media (min-width: 769px) {
  /* Arrow positioning */
  [dir="rtl"] .nav-arrow {
    margin-left: 0;
    margin-right: auto;
  }

  /* Top-level submenus in RTL: Default align to left (visually right) */
  [dir="rtl"] .nav-submenu {
    left: auto !important;
    right: 0 !important;
  }

  /* RTL: When flip-left is applied, align to right edge (visually left) */
  [dir="rtl"] .nav-item.flip-left > .nav-submenu {
    left: 0 !important;
    right: auto !important;
  }

  /* User menu in RTL: Also default to left alignment */
  [dir="rtl"] .nav-user-menu > .nav-submenu {
    left: auto !important;
    right: 0 !important;
  }

  /* User menu in RTL: When flip-left, align to right */
  [dir="rtl"] .nav-user-menu.flip-left > .nav-submenu {
    left: 0 !important;
    right: auto !important;
  }

  /* Nested submenus in RTL: Default fly out to left */
  [dir="rtl"] .nav-submenu .nav-submenu {
    left: auto !important;
    right: 100% !important;
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
  }

  /* Nested submenus in RTL: When flip-left, fly out to right */
  [dir="rtl"] .nav-submenu .nav-item.flip-left > .nav-submenu {
    left: 100% !important;
    right: auto !important;
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
  }

  /* Arrow directions in RTL nested menus */
  [dir="rtl"] .nav-submenu .nav-arrow {
    transform: rotate(90deg); /* Point left in RTL */
  }

  [dir="rtl"] .nav-submenu .nav-item.flip-left > .nav-toggle-submenu .nav-arrow {
    transform: rotate(-90deg); /* Point right when flipped in RTL */
  }

  /* Bridge areas for RTL */
  [dir="rtl"] .nav-submenu .nav-item.has-submenu::after {
    left: auto;
    right: 100%;
  }

  [dir="rtl"] .nav-submenu .nav-item.flip-left.has-submenu::after {
    left: 100%;
    right: auto;
  }
}

/* File: nav-logo-additions.css */
/* Add these styles to your nav-FINAL.css */

/* ========================================
   BRAND LOGO STYLES
   ======================================== */

/* Brand container - already exists, enhanced here */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.2s;
  z-index: 1001;
}

.nav-brand:hover {
  opacity: 0.9;
}

/* Logo container - all types */
.nav-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Brand name text */
.nav-brand-name {
  font-size: 1.75rem;
  font-weight: 700;
}

/* ========================================
   EMOJI LOGO
   ======================================== */
.nav-brand-emoji {
  font-size: 2rem;
  line-height: 1;
}

/* ========================================
   SVG LOGO
   ======================================== */
.nav-brand-svg {
  width: 32px;
  height: 32px;
}

.nav-brand-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ========================================
   IMAGE LOGO
   ======================================== */
.nav-brand-image {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* ========================================
   ICON FONT LOGO (Font Awesome, etc.)
   ======================================== */
.nav-brand-icon {
  font-size: 1.5rem;
}

/* ========================================
   MOBILE ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {
  .nav-brand {
    gap: 0.35rem;
  }

  .nav-brand-name {
    font-size: 1.5rem;
  }
  
  .nav-brand-emoji {
    font-size: 1.5rem;
  }
  
  .nav-brand-svg,
  .nav-brand-image {
    width: 28px;
    height: 28px;
  }
  
  .nav-brand-icon {
    font-size: 1.25rem;
  }
}

/* ========================================
   OPTIONAL: Hide name on very small screens
   ======================================== */
@media (max-width: 480px) {
  /* Uncomment to hide brand name on tiny screens */
  /* .nav-brand-name {
    display: none;
  } */
}