/* ============================================
   NAVIGATION & DROPDOWN STYLES
   ============================================ */

/* Business Menu Dropdown - Opens to the right */
#businessMenuDropdown,
#businessMenuDropdownMobile {
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

#businessMenuDropdown button,
#businessMenuDropdownMobile button {
  border-radius: var(--radius-lg);
  margin: 0.25rem;
}

#businessMenuDropdown button:hover,
#businessMenuDropdownMobile button:hover {
  transform: translateX(2px);
}

.restaurant-selector-compact button {
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-md);
}

.restaurant-selector-compact button:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Mobile Business Menu Bottom Sheet */
.business-menu-bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 10001; /* Above mobile bottom nav (z-index: 400) */
  pointer-events: none;
}

.business-menu-bottom-sheet:not(.hidden) {
  pointer-events: auto;
}

.business-menu-bottom-sheet:not(.hidden) .bottom-sheet-overlay {
  opacity: 1;
}

.business-menu-bottom-sheet:not(.hidden) .bottom-sheet-content {
  transform: translateY(0);
}

/* Mobile: Show top nav, hide sidebar */
@media (max-width: 1199px) {
  .mobile-only-top-nav {
    display: flex !important;
  }

  .compact-top-nav {
    height: 56px;
    min-height: 56px;
    margin-top: 1rem;
    margin-left: 1.25rem;
    margin-right: 1.25rem;
    max-width: calc(100% - 2.5rem);
    box-sizing: border-box;
  }

  .compact-top-nav .nav-content {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .sidebar-business-button-mobile {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .business-menu-compact #currentRestaurantNameMobile {
    max-width: 140px !important;
  }

  .sidebar-logo-wrapper-mobile {
    width: 36px;
    height: 36px;
  }

  .sidebar-logo-wrapper-mobile img {
    width: 28px;
    height: 28px;
  }
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-white);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: var(--z-modal-backdrop);
  display: none;
  height: 80px; /* Fixed height for consistent spacing */
  min-height: 80px;
}

/* Responsive Layout - iPad and smaller get mobile nav, computers get sidebar */
@media (max-width: 1199px) {
  .mobile-bottom-nav {
    display: flex;
  }

  .sidebar-clean {
    display: none !important;
  }

  /* Exception: Show sidebar in tables section for tablet/mobile */
  #tables-section .sidebar-clean {
    display: block !important;
  }

  /* Show mobile menu selector when bottom nav is visible */
  #mobileMenuSelector {
    display: block !important;
  }

  /* Show mobile PDF section when bottom nav is visible */
  #mobileMenuPDFsSection {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Adjust main content padding for mobile */
  .content-with-sidebar {
    padding-bottom: 100px; /* Extra space for bottom nav (80px + 20px buffer) */
    margin-bottom: 0;
  }

  /* Ensure the main dashboard container accounts for mobile nav */
  #adminDashboard {
    padding-bottom: 0; /* Remove any existing padding */
    height: 100vh; /* Full viewport height */
    overflow: hidden; /* Prevent scrolling on main container */
  }

  /* Make sure content sections have proper spacing */
  .content-section {
    padding-bottom: 20px; /* Extra padding for content sections */
    min-height: calc(100vh - 100px); /* Ensure content takes full height minus nav */
  }

  /* Ensure the main content area can scroll properly */
  #dashboardMain {
    height: calc(100vh - 100px) !important; /* Full height minus mobile nav */
    max-height: calc(100vh - 100px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
    padding-bottom: 50px !important; /* Extra space to prevent navbar from covering content */
  }

  /* Ensure content sections can grow and scroll */
  .content-section {
    overflow: visible !important;
    min-height: auto !important;
  }
}

/* Hide mobile menu selector on desktop (when sidebar is visible) */
@media (min-width: 1200px) {
  #mobileMenuSelector {
    display: none !important;
  }

  /* Hide mobile PDF section on desktop (when sidebar is visible) */
  #mobileMenuPDFsSection {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }

  /* Ensure the main content area can scroll properly on desktop/laptop */
  #dashboardMain {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: 100% !important;
    max-height: 100vh !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Ensure adminDashboard allows scrolling */
  #adminDashboard {
    overflow: hidden !important; /* Container doesn't scroll */
    height: 100vh !important;
  }

  /* Ensure content sections can grow and scroll */
  .content-section {
    overflow: visible !important;
    min-height: auto !important;
  }

  /* Ensure grids work properly on desktop/laptop - don't override Tailwind classes */
  /* Let Tailwind's responsive grid classes work naturally */
  .grid[class*='grid-cols-'] {
    /* Don't force single column - let Tailwind handle it */
  }

  /* Explicitly ensure common grid patterns work */
  .grid.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .grid.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .grid.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .grid.grid-cols-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 1200px) {
  .mobile-bottom-nav {
    display: none;
  }

  .sidebar-clean {
    display: block !important;
  }
}

/* Top Navigation - Mobile */
@media (max-width: 1199px) {
  nav.holded-card {
    margin: 0.75rem !important;
    padding: 0.75rem !important;
    max-width: calc(100% - 1.5rem) !important;
    overflow: visible !important; /* Allow dropdown to overflow */
    position: relative !important;
    z-index: auto !important; /* Don't create stacking context */
  }

  /* Ensure all parent containers allow overflow */
  nav.holded-card > div,
  nav.holded-card > div > div,
  nav.holded-card > div > div > div {
    overflow: visible !important;
  }

  nav.holded-card .flex {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* Restaurant dropdown - Base styles */
#restaurantDropdown {
  z-index: 100 !important;
  border-radius: 0.5rem !important;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
  width: max-content !important;
  min-width: fit-content !important;
}

/* Remove holded-card styling from dropdown */
#restaurantDropdown.holded-card {
  background: white !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Restaurant dropdown items - no borders */
#restaurantDropdownList > button,
#restaurantDropdownList > a {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}

/* Remove any top border from dropdown content */
#restaurantDropdown > div:first-child {
  border-top: none !important;
}

/* Restaurant dropdown - Mobile fixes */
@media (max-width: 640px) {
  /* Ensure parent doesn't clip dropdown */
  nav.holded-card {
    overflow: visible !important;
    z-index: auto !important;
  }

  /* Parent container for dropdown */
  nav.holded-card > div > div > div.relative {
    z-index: 10002 !important;
    position: relative !important;
  }

  #restaurantDropdown:not(.hidden) {
    position: fixed !important; /* Use fixed positioning on mobile */
    z-index: 10002 !important; /* Above everything including modals */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2) !important;
    background: white !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    border-radius: var(--radius-lg) !important;
  }

  /* When hidden, actually hide it */
  #restaurantDropdown.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Ensure dropdown items are touch-friendly */
  #restaurantDropdown button,
  #restaurantDropdown a {
    min-height: 44px !important;
    padding: 0.75rem 1rem !important;
  }
}

/* Desktop dropdown - Keep absolute positioning */
@media (min-width: 641px) {
  #restaurantDropdown:not(.hidden) {
    position: fixed !important;
    z-index: 10002 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: max-content !important;
    min-width: fit-content !important;
    max-width: none !important;
  }

  #restaurantDropdown.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }
}

/* Fix sidebar menu items */
@media (max-width: 1199px) {
  .menu-sidebar-item,
  .sidebar-clean > * {
    max-width: 100% !important;
  }
}
