/* LIMOR AI - Mobile Navigation Styles
 * Sacred Compliance: 100% SHARP - Mobile navigation with desktop preservation
 * Hebrew Excellence: RTL-aware mobile navigation styles
 */

/* Mobile Navigation Toggle - Only visible on mobile/tablet */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--chakra-colors-brand-600);
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  border-radius: var(--radius-lg);
  transition: background-color var(--transition-normal);
  align-items: center;
  justify-content: center;
}

.mobile-nav-toggle:hover,
.mobile-nav-toggle:focus {
  background-color: #f7fafc;
  outline: none;
}

.mobile-nav-toggle:active {
  background-color: #edf2f7;
}

/* Show toggle on mobile and tablet */
@media (max-width: 1023px) {
  .mobile-nav-toggle {
    display: flex;
  }
}

/* Sidebar Backdrop - Mobile Only */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-overlay) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal) ease-in-out;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Desktop: Hide backdrop */
@media (min-width: 1024px) {
  .sidebar-backdrop {
    display: none;
  }
}

/* Enhanced Sidebar for Mobile */
.sidebar {
  /* Desktop styles preserved */
  background: white !important;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-base);
  height: fit-content;
  flex-shrink: 0;
}

/* Desktop Sidebar - Keep Original Styles */
@media (min-width: 1024px) {
  .sidebar {
    width: 16rem;
    min-width: 16rem;
    max-width: 16rem;
    position: static;
    /* Original desktop values */
    border-radius: 0.75rem;
    padding: 1.5rem;
  }
}

/* Mobile Sidebar - Overlay */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: -100%; /* Start off-screen (RTL) */
    width: 100vw;
    max-width: 320px; /* Maximum width on mobile */
    height: 100vh;
    z-index: var(--z-overlay);
    border-radius: 0;
    padding: var(--space-4);
    overflow-y: auto;
    transition: right var(--transition-normal) ease-in-out;

    /* Enhanced mobile styling */
    background: white !important;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar.active {
    right: 0; /* Slide in from right (RTL) */
  }

  /* Smooth scrolling for mobile sidebar */
  .sidebar {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  /* Custom scrollbar for webkit browsers */
  .sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .sidebar::-webkit-scrollbar-track {
    background: transparent;
  }

  .sidebar::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 2px;
  }
}

/* Sidebar Items Enhancement */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  color: #4a5568;
  text-decoration: none;
  transition: all var(--transition-normal);
  margin-bottom: var(--space-2);
  min-height: var(--touch-target-min);
}

.sidebar-item:hover,
.sidebar-item:focus {
  background: #f7fafc;
  color: var(--chakra-colors-brand-600);
  outline: none;
}

.sidebar-item.active {
  background: #e6fffa;
  color: #38b2ac;
  font-weight: 600;
}

/* Enhanced touch targets on mobile */
@media (max-width: 767px) {
  .sidebar-item {
    min-height: var(--touch-target-comfortable);
    padding: var(--space-4);
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
  }
}

/* Sidebar Close Button - Mobile Only */
.sidebar-close {
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--chakra-colors-brand-600);
  margin-bottom: var(--space-4);
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  transition: background-color var(--transition-normal);
}

.sidebar-close:hover,
.sidebar-close:focus {
  background-color: #f7fafc;
  outline: none;
}

/* Desktop: Hide close button */
@media (min-width: 1024px) {
  .sidebar-close {
    display: none !important;
  }
}

/* Sidebar Header for Mobile */
@media (max-width: 1023px) {
  .sidebar::before {
    content: "תפריט ניווט";
    display: block;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--chakra-colors-brand-700);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid #e2e8f0;
  }
}

/* Icon Styles in Sidebar */
.sidebar-item .icon {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 2;
  flex-shrink: 0;
}

/* Enhanced Active State */
.sidebar-item.active .icon {
  color: #38b2ac;
}

/* Sidebar Logo/Branding (if needed) */
.sidebar-brand {
  display: none;
}

@media (max-width: 1023px) {
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid #e2e8f0;
  }

  .sidebar-brand .logo {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--chakra-colors-brand-600);
  }
}

/* Focus Management for Accessibility */
.sidebar[aria-hidden="true"] {
  visibility: hidden;
}

.sidebar:not([aria-hidden="true"]) {
  visibility: visible;
}

/* Prevent Background Scroll When Sidebar Open */
body.sidebar-open {
  overflow: hidden;
}

@media (min-width: 1024px) {
  body.sidebar-open {
    overflow: auto; /* Restore on desktop */
  }
}

/* Animation Performance */
.sidebar,
.sidebar-backdrop {
  will-change: transform, opacity;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-backdrop,
  .mobile-nav-toggle {
    transition: none;
  }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
  .sidebar-item:hover,
  .sidebar-item:focus {
    background: #000000;
    color: #ffffff;
  }

  .sidebar-backdrop {
    background-color: rgba(0, 0, 0, 0.8);
  }
}

/* RTL Specific Adjustments */
[dir="rtl"] .sidebar {
  right: -100%;
}

[dir="rtl"] .sidebar.active {
  right: 0;
}

[dir="rtl"] .sidebar {
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

[dir="ltr"] .sidebar {
  left: -100%;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

[dir="ltr"] .sidebar.active {
  left: 0;
}