/* Professional Mobile Menu Improvements */

/* Reset and base styles for mobile nav */
.mobile-nav-container * {
  box-sizing: border-box;
}

.mobile-nav-container ul,
.mobile-nav-container li {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Hide mobile nav container by default */
.mobile-nav-container {
  display: none;
}

/* Show only desktop nav by default */
.nav-menu.desktop-nav {
  display: flex;
}

/* Enhanced mobile navigation with sidebar-style layout */
@media (max-width: 768px) {
  
  /* Hide desktop nav on mobile */
  .nav-menu.desktop-nav {
    display: none !important;
  }

  /* Main mobile navigation container */
  #nav-toggle:checked ~ nav .mobile-nav-container {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 320px;
    max-width: 85vw;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow-y: auto;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
  }

  /* Animation for menu opening */
  @keyframes slideInRight {
    from {
      transform: translateX(100%);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  /* Menu header with logo and close button */
  .menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #2980b9 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }

  .menu-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
  }

  .menu-logo img {
    width: 32px;
    height: 32px;
  }

  .menu-close {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .menu-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
  }

  /* Menu content area with better spacing */
  .menu-content {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
  }

  /* Default collapsed state for better initial UX */
  .menu-category.collapsible {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  .menu-category.collapsible:last-of-type {
    border-bottom: none;
  }

  /* Start with categories collapsed by default for cleaner look */
  .menu-category.collapsible.collapsed .category-content {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
  }

  /* Category content (collapsible) */
  .category-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease,
                padding 0.3s ease;
    opacity: 1;
    background: rgba(255, 255, 255, 0.3);
    list-style: none;
    margin: 0;
    padding: 0;
  }

  /* Ensure list items are properly styled */
  .category-content li {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  /* Category sections */
  .menu-category {
    margin-bottom: 0.5rem;
  }

  /* Quick Actions - Always visible, special styling */
  .menu-category.quick-actions {
    background: rgba(var(--primary-color-rgb), 0.05);
    border-radius: 8px;
    margin: 0 1rem 1rem 1rem;
    padding: 0.5rem 0;
  }

  .menu-category.quick-actions ul {
    margin: 0;
    padding: 0;
  }

  .menu-category.quick-actions li a {
    padding: 0.8rem 1rem !important;
    font-weight: 600 !important;
  }

  .menu-category.quick-actions li a.primary-action {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2980b9 100%) !important;
    color: white !important;
    border-radius: 6px !important;
    margin: 0.25rem !important;
  }

  .menu-category.quick-actions li a.primary-action i {
    color: white !important;
  }

  .menu-category.quick-actions li a.primary-action:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.3) !important;
  }

  /* Collapsible category headers */
  .menu-category.collapsible .menu-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  .menu-category.collapsible .menu-category-header:hover {
    background: rgba(var(--primary-color-rgb), 0.08);
    color: var(--primary-color);
  }

  .menu-category.collapsible .menu-category-header:active {
    background: rgba(var(--primary-color-rgb), 0.12);
  }

  .category-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .category-title i {
    color: var(--primary-color);
    font-size: 1rem;
  }

  .collapse-icon {
    font-size: 0.8rem;
    color: var(--text-color-light);
    transition: transform 0.3s ease, color 0.2s ease;
  }

  .menu-category.collapsible .menu-category-header:hover .collapse-icon {
    color: var(--primary-color);
  }

  /* Collapsed state */
  .menu-category.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
  }

  /* Category content (collapsible) */
  .category-content {
    max-height: 1000px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
  }

  .menu-category.collapsible.collapsed .category-content {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  /* Old menu-category-header styling for non-collapsible */
  .menu-category:not(.collapsible) .menu-category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color-light);
    background: rgba(var(--primary-color-rgb), 0.05);
    border-left: 3px solid var(--primary-color);
    margin-bottom: 0.5rem;
  }

  .menu-category:not(.collapsible) .menu-category-header i {
    color: var(--primary-color);
  }

  /* Menu category lists */
  .menu-category ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .menu-category li {
    margin: 0;
  }

  /* Fix for quick actions styling */
  .menu-category.quick-actions ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .menu-category.quick-actions li {
    margin: 0;
  }

  /* Menu items in collapsible categories */
  .menu-category.collapsible li a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: 44px;
    position: relative;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  .menu-category.collapsible li:last-child a {
    border-bottom: none;
  }

  /* Menu item icons in collapsible categories */
  .menu-category.collapsible li a i {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1rem;
    flex-shrink: 0;
  }

  /* Menu item hover effects for collapsible categories */
  .menu-category.collapsible li a:hover,
  .menu-category.collapsible li a:focus {
    background: linear-gradient(90deg, rgba(var(--primary-color-rgb), 0.08) 0%, transparent 100%);
    color: var(--primary-color);
    padding-left: 2rem;
    transform: translateX(3px);
  }

  .menu-category.collapsible li a:hover i,
  .menu-category.collapsible li a:focus i {
    transform: scale(1.1);
    color: var(--primary-color);
  }

  /* Special styling for logout link */
  .logout-item a {
    color: #e74c3c !important;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: 0.5rem;
    padding-top: 1.25rem;
  }

  .logout-item a i {
    color: #e74c3c !important;
  }

  .logout-item a:hover {
    background: linear-gradient(90deg, rgba(231, 76, 60, 0.1) 0%, transparent 100%);
    border-left-color: #e74c3c;
  }

  /* Special styling for premium link */
  .premium-link {
    background: linear-gradient(90deg, rgba(255, 193, 7, 0.1) 0%, transparent 100%) !important;
    color: #f39c12 !important;
    font-weight: 600 !important;
  }

  .premium-link i {
    color: #f39c12 !important;
  }

  .premium-link:hover {
    background: linear-gradient(90deg, rgba(255, 193, 7, 0.2) 0%, transparent 100%) !important;
    border-left-color: #f39c12 !important;
  }

  /* Menu divider */
  .menu-divider {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }

  /* Menu overlay */
  #nav-toggle:checked ~ nav::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    animation: fadeIn 0.3s ease-out;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Hamburger menu improvements */
  .nav-toggle-label {
    display: flex !important;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 21px;
    cursor: pointer;
    padding: 4px;
    z-index: 1002;
    position: relative;
  }

  .nav-toggle-label span {
    display: block;
    height: 3px;
    width: 100%;
    background: var(--dark-color);
    border-radius: 3px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center;
  }

  /* Animated hamburger to X */
  #nav-toggle:checked + .nav-toggle-label span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
    background: var(--primary-color);
  }

  #nav-toggle:checked + .nav-toggle-label span:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px);
  }

  #nav-toggle:checked + .nav-toggle-label span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
    background: var(--primary-color);
  }

  /* Menu footer with app info */
  .menu-footer {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: auto;
  }

  .menu-footer .app-version {
    font-size: 0.8rem;
    color: var(--text-color-light);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }

  .menu-footer .app-version i {
    color: var(--primary-color);
  }

  /* Responsive adjustments for very small screens */
  @media (max-width: 480px) {
    #nav-toggle:checked ~ nav .mobile-nav-container {
      width: 100vw;
      max-width: 100vw;
    }
  }

  /* Override old mobile menu styles */
  #nav-toggle:checked~nav .nav-menu {
    display: none !important;
  }

  /* Ensure only our new mobile nav shows */
  #nav-toggle:checked ~ nav .mobile-nav-container {
    display: flex !important;
  }
}

/* Dark mode support for mobile menu */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  #nav-toggle:checked ~ nav .mobile-nav-container {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #ffffff;
  }

  .menu-category-header {
    background: rgba(255, 255, 255, 0.05);
    color: #cccccc;
  }

  .menu-category li a {
    color: #ffffff;
  }

  .menu-category li a:hover {
    background: linear-gradient(90deg, rgba(var(--primary-color-rgb), 0.2) 0%, transparent 100%);
  }

  .menu-footer {
    background: rgba(255, 255, 255, 0.02);
    border-top-color: rgba(255, 255, 255, 0.1);
  }
}
