/* ============================================================
   MGL — Menú Hamburguesa Nativo Compartido
   Compatible con todas las páginas de la app
   ============================================================ */

/* --- Botón Hamburguesa (solo visible en mobile) --- */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 10px;
  transition: background 0.2s ease;
  margin-left: auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:active {
  background: rgba(15, 23, 42, 0.06);
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}

.hamburger-line {
  display: block;
  height: 2px;
  width: 100%;
  background: #0f172a;
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

/* Estado abierto — convierte en X */
.mobile-menu-btn.open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mobile-menu-btn.open .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mobile-menu-btn.open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --- Backdrop / Overlay --- */
.mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 99998;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none; /* NO bloquear clics cuando está oculto */
}

.mobile-nav-backdrop.visible {
  opacity: 1;
  pointer-events: auto; /* Solo interceptar clics cuando está visible */
}

/* --- Drawer lateral (slide desde derecha) --- */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(80vw, 300px);
  height: 100dvh;
  height: 100vh;
  background: #ffffff;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.12);
  padding-bottom: env(safe-area-inset-bottom, 1rem);
  border-radius: 0;
  overflow-y: auto;
}

.mobile-nav-drawer.open {
  transform: translateX(0);
}

/* Cabecera del Drawer */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}

.drawer-brand {
  font-family: 'Outfit', sans-serif;
  font-weight: 850;
  font-size: 1.05rem;
  color: #0f172a;
  letter-spacing: -0.5px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.drawer-brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.5px;
  background: #f1f5f9;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  width: fit-content;
}

.drawer-close-btn {
  background: rgba(15, 23, 42, 0.05);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
  font-size: 1.1rem;
  transition: background 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.drawer-close-btn:active {
  background: rgba(15, 23, 42, 0.1);
}

/* Links de Navegación */
.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem 1rem;
  flex: 1;
}

.drawer-nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  padding: 0.95rem 1.1rem;
  border-radius: 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #334155;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}

.drawer-nav-link:active {
  transform: scale(0.98);
}

.drawer-nav-link:hover {
  background: rgba(15, 23, 42, 0.04);
}

/* Íconos del drawer */
.drawer-nav-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* Estados activos por rol */
.drawer-nav-link.active-client {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.07);
  border-color: rgba(139, 92, 246, 0.12);
}
.drawer-nav-link.active-client .drawer-nav-icon {
  background: rgba(139, 92, 246, 0.1);
}

.drawer-nav-link.active-driver {
  color: #f97316;
  background: rgba(249, 115, 22, 0.07);
  border-color: rgba(249, 115, 22, 0.12);
}
.drawer-nav-link.active-driver .drawer-nav-icon {
  background: rgba(249, 115, 22, 0.1);
}

.drawer-nav-link.active-admin {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.07);
  border-color: rgba(2, 132, 199, 0.12);
}
.drawer-nav-link.active-admin .drawer-nav-icon {
  background: rgba(2, 132, 199, 0.1);
}

.drawer-nav-link.active-tutorial {
  color: #6366f1;
  background: rgba(99, 102, 241, 0.07);
  border-color: rgba(99, 102, 241, 0.12);
}
.drawer-nav-link.active-tutorial .drawer-nav-icon {
  background: rgba(99, 102, 241, 0.1);
}

/* Footer del drawer — selector de idioma */
.drawer-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.drawer-lang-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 0.5rem;
  display: block;
}

.drawer-lang-select {
  width: 100%;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  color: #0f172a;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  outline: none;
  cursor: pointer;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23475569' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ============================================================
   Activación de controles mobile (solo pantallas < 768px)
   ============================================================ */
@media (max-width: 767px) {
  .mobile-menu-btn {
    display: flex;
  }

  /* Backdrop visible en DOM pero sin bloquear clics (pointer-events: none por defecto) */
  .mobile-nav-backdrop {
    display: block;
  }

  /* Ocultar nav desktop en móvil */
  .demo-top-bar .demo-links {
    display: none !important;
  }

  /* Hacer que el top bar quede: logo | idioma + hamburguesa */
  .demo-top-bar {
    padding: 0 1rem;
    gap: 0.75rem;
  }

  .demo-logo {
    display: flex !important;
    flex: 1;
    min-width: 0;
  }

  .demo-logo > :first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Selector de idioma compacto en top bar (desktop-only) — oculto, está en el drawer */
  .demo-top-bar .demo-lang-wrapper {
    display: none !important;
  }
}

/* Pantallas grandes: ocultar el drawer y el botón hamburguesa */
@media (min-width: 768px) {
  .mobile-menu-btn { display: none !important; }
  .mobile-nav-drawer { display: none !important; }
  .mobile-nav-backdrop { display: none !important; }
}
