/* ============================================
   MOBILE MENU - DRAWER LATERAL
   Menú móvil independiente con UX nativa
   ============================================ */

/* Desktop: Menú normal (sin cambios) */
@media (min-width: 768px) {
  .mobile-menu-overlay,
  .mobile-menu-drawer,
  .mobile-menu-toggle {
    display: none !important;
  }
}

/* Mobile: Drawer lateral */
@media (max-width: 767px) {
  /* Ocultar menú desktop en móvil */
  .sticky-header-nav {
    display: none !important;
  }

  /* Mostrar el botón del sticky header en móvil */
  .sticky-header-menu-btn {
    display: flex !important;
  }

  /* Botón hamburguesa */
  .mobile-menu-toggle,
  .sticky-header-menu-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: hsl(var(--primary));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s;
  }

  .mobile-menu-toggle:active,
  .sticky-header-menu-btn:active {
    transform: scale(0.95);
  }

  .mobile-menu-toggle span {
    position: relative;
    width: 20px;
    height: 2px;
    background: white;
    display: block;
    transition: all 0.3s;
  }

  .mobile-menu-toggle span::before,
  .mobile-menu-toggle span::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: white;
    transition: all 0.3s;
  }

  .mobile-menu-toggle span::before {
    top: -6px;
  }

  .mobile-menu-toggle span::after {
    top: 6px;
  }

  /* Animación X cuando está abierto */
  .mobile-menu-toggle.active span,
  .sticky-header-menu-btn.active svg {
    background: transparent;
  }

  .mobile-menu-toggle.active span::before {
    top: 0;
    transform: rotate(45deg);
  }

  .mobile-menu-toggle.active span::after {
    top: 0;
    transform: rotate(-45deg);
  }

  /* Animación para el botón del sticky header */
  .sticky-header-menu-btn.active svg {
    transform: rotate(90deg);
  }

  /* Overlay oscuro */
  .mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    backdrop-filter: blur(2px);
  }

  .mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* Drawer lateral */
  .mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: hsl(var(--background));
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
  }

  .mobile-menu-drawer.active {
    transform: translateX(0);
  }

  /* Header del drawer */
  .mobile-menu-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .mobile-menu-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
  }

  .mobile-menu-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0;
  }

  /* Lista de navegación */
  .mobile-menu-nav {
    padding: 1rem 0;
  }

  .mobile-menu-item {
    border-bottom: 1px solid hsl(var(--border) / 0.3);
  }

  .mobile-menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    color: hsl(var(--foreground));
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-menu-link:active {
    background: hsl(var(--primary) / 0.1);
  }

  /* Ícono de expandir */
  .mobile-menu-expand {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
  }

  .mobile-menu-expand svg {
    width: 16px;
    height: 16px;
    stroke: hsl(var(--muted-foreground));
  }

  .mobile-menu-item.expanded .mobile-menu-expand {
    transform: rotate(180deg);
  }

  /* Submenú acordeón */
  .mobile-submenu {
    max-height: 0;
    overflow: hidden;
    background: hsl(var(--muted) / 0.3);
    transition: max-height 0.3s ease;
  }

  .mobile-menu-item.expanded .mobile-submenu {
    max-height: 300px;
  }

  .mobile-submenu a {
    display: block;
    padding: 0.875rem 1.25rem 0.875rem 2.5rem;
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-submenu a:active {
    background: hsl(var(--primary) / 0.1);
    border-left-color: hsl(var(--primary));
    color: hsl(var(--primary));
  }

  /* Login button */
  .mobile-menu-login {
    margin: 1rem 1.25rem;
    padding: 0.875rem;
    background: hsl(var(--primary));
    color: white;
    text-align: center;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    display: block;
    transition: transform 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-menu-login:active {
    transform: scale(0.98);
  }

  /* Prevenir scroll del body */
  body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}
