/* ============================================================================
   MOBILE NAVIGATION SYSTEM V2
   Only active on screens ≤768px
   Desktop navigation remains completely unchanged
   ============================================================================ */

/* Desktop navigation: Hide mobile elements completely */
@media (min-width: 769px) {
  #mobile-topbar,
  #mobile-drawer {
    display: none !important;
  }
}

/* Mobile navigation: Show mobile elements, hide desktop topbar and sidebar */
@media (max-width: 768px) {
  /* Hide desktop topbar and sidebar */
  #topbar {
    display: none !important;
  }

  #app-sidebar {
    display: none !important;
  }

  /* Adjust main content for mobile */
  #main-content {
    padding: 1rem;
    margin-top: 64px; /* Height of mobile top bar */
  }

  /* ===== MOBILE TOP BAR ===== */
  .mobile-topbar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1195;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 64px;
    pointer-events: auto;
  }

  .mobile-topbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 100%;
    max-width: 100%;
  }

  /* Brand text: sized to prevent wrapping on small phones */
  .mobile-brand {
    flex: 1;
    min-width: 0; /* Allow flex item to shrink below content size */
  }

  .mobile-brand-text {
    background-image: linear-gradient(90deg, #0B0B0B 0%, #C0C6CF 48%, #FFFFFF 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-size: 1.125rem; /* 18px - sized for readability on mobile */
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  }

  /* Fallback for browsers without background-clip support */
  .no-bgclip .mobile-brand-text {
    color: #111827;
  }

  /* Mobile actions container */
  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
  }

  /* Icon buttons: minimum 44x44px touch targets (WCAG 2.5.5) */
  .mobile-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    transition: all 0.2s ease;
    cursor: pointer;
  }

  .mobile-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
  }

  .mobile-icon-btn:active {
    transform: scale(0.95);
  }

  .mobile-icon-btn:focus {
    outline: 2px solid var(--royal);
    outline-offset: 2px;
  }

  /* Avatar circle in mobile top bar */
  .mobile-avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--royal), var(--sky));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
  }

  /* Profile button specific styling */
  .btn-profile {
    z-index: 1196;
    pointer-events: auto;
    text-decoration: none;
  }

  .btn-profile:hover {
    text-decoration: none;
  }

  /* ===== MOBILE DRAWER ===== */
  .mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200; /* Above mobile topbar (1195) and profile (1196), above cookie banner (60) */
    pointer-events: none; /* Allow clicks through when closed */
    visibility: hidden;
  }

  .mobile-drawer[aria-hidden="false"] {
    pointer-events: auto;
    visibility: visible;
  }

  /* Backdrop */
  .mobile-drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 250ms ease;
  }

  .mobile-drawer[aria-hidden="false"] .mobile-drawer-backdrop {
    opacity: 1;
  }

  /* Drawer panel */
  .mobile-drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80vw;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 250ms ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  .mobile-drawer[aria-hidden="false"] .mobile-drawer-panel {
    transform: translateX(0);
  }

  /* Drawer header with close button */
  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .mobile-drawer-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    transition: all 0.2s ease;
    cursor: pointer;
  }

  .mobile-drawer-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
  }

  .mobile-drawer-close-btn:focus {
    outline: 2px solid var(--royal);
    outline-offset: 2px;
  }

  /* Drawer content area */
  .mobile-drawer-content {
    padding: 0.5rem;
  }

  /* Navigation items */
  .mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem; /* 14px vertical for comfortable touch */
    border-radius: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    width: 100%;
    min-height: 48px; /* Ensure minimum touch target height */
  }

  .mobile-nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }

  .mobile-nav-item:focus {
    outline: 2px solid var(--royal);
    outline-offset: 2px;
  }

  /* Active navigation item */
  .mobile-nav-active {
    background-color: #7DD3FC; /* Light sky blue */
    color: #0F172A; /* Dark text */
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);
  }

  .mobile-nav-active:hover {
    background-color: #38BDF8;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  }

  /* Navigation icon */
  .mobile-nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
  }

  /* Navigation label */
  .mobile-nav-label {
    font-size: 0.9375rem; /* 15px for readability */
    font-weight: 500;
    flex: 1;
  }

  /* Pro badge */
  .mobile-nav-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--royal);
    color: white;
    border-radius: 0.375rem;
    flex-shrink: 0;
  }

  /* Navigation sections */
  .mobile-nav-section {
    margin-top: 1.5rem;
  }

  .mobile-nav-section-title {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* Prevent body scroll when drawer is open */
  body.mobile-drawer-open {
    overflow: hidden;
  }

  /* Extra small phones (≤375px) - adjust brand text size */
  @media (max-width: 375px) {
    .mobile-brand-text {
      font-size: 1rem; /* 16px for very small screens */
    }
  }
}
