/* Estilos para el navbar móvil */
:root {
  --mobile-nav-height: 60px;
  --mobile-nav-bg: rgba(20, 20, 30, 0.85);
  --mobile-nav-light-bg: rgba(255, 255, 255, 0.9);
  --mobile-nav-border: rgba(255, 255, 255, 0.1);
  --mobile-nav-light-border: rgba(0, 0, 0, 0.05);
  --mobile-nav-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
  --mobile-nav-light-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
  --mobile-nav-item-active: rgba(var(--primary-rgb), 0.2);
  --mobile-nav-item-active-light: rgba(var(--primary-rgb), 0.1);
  --mobile-nav-transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Contenedor principal del navbar móvil */
.mobile-navbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background: var(--mobile-nav-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-top: 1px solid var(--mobile-nav-border);
  box-shadow: var(--mobile-nav-shadow);
  z-index: 1000;
  transition: var(--mobile-nav-transition);
}

body.light-mode .mobile-navbar {
  background: var(--mobile-nav-light-bg);
  border-top: 1px solid var(--mobile-nav-light-border);
  box-shadow: var(--mobile-nav-light-shadow);
}

/* Menú de navegación */
.mobile-nav-menu {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  padding: 0;
  margin: 0;
  list-style: none;
}

/* Elementos del menú */
.mobile-nav-item {
  flex: 1;
  height: 100%;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: rgba(var(--light-rgb), 0.7);
  text-decoration: none;
  transition: var(--mobile-nav-transition);
  padding: 0.5rem;
}

body.light-mode .mobile-nav-link {
  color: rgba(var(--dark-rgb), 0.7);
}

.mobile-nav-link:hover,
.mobile-nav-link:focus {
  color: var(--primary);
}

.mobile-nav-link.active {
  color: var(--primary);
  background: var(--mobile-nav-item-active);
}

body.light-mode .mobile-nav-link.active {
  background: var(--mobile-nav-item-active-light);
}

/* Iconos del menú */
.mobile-nav-icon {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
  transition: var(--mobile-nav-transition);
}

.mobile-nav-link:hover .mobile-nav-icon,
.mobile-nav-link:focus .mobile-nav-icon,
.mobile-nav-link.active .mobile-nav-icon {
  transform: translateY(-4px);
}

/* Texto del menú */
.mobile-nav-text {
  font-size: 0.7rem;
  font-weight: 500;
  transition: var(--mobile-nav-transition);
}

/* Estilo especial para el texto del perfil */
.mobile-user-menu .mobile-nav-text {
  font-weight: 600;
  background: linear-gradient(to right, var(--primary-light), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Botón central especial */
.mobile-nav-center {
  transform: translateY(-15px);
  position: relative;
  z-index: 1001;
}

.mobile-nav-center-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.4);
  transition: var(--mobile-nav-transition);
}

.mobile-nav-center-btn:hover,
.mobile-nav-center-btn:focus {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.5);
}

/* Menú de usuario - Diseño mejorado */
.mobile-user-menu {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mobile-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  margin-bottom: 0.25rem;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.4);
  transition: all 0.3s ease;
}

.mobile-user-avatar:hover,
.mobile-user-menu:hover .mobile-user-avatar {
  transform: scale(1.1);
  border-color: var(--primary-light);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.6);
}

.mobile-user-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.4);
  transition: all 0.3s ease;
}

.mobile-user-avatar-placeholder:hover,
.mobile-user-menu:hover .mobile-user-avatar-placeholder {
  transform: scale(1.1);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.6);
}

/* Indicador de notificaciones - Diseño mejorado */
.mobile-notification-badge {
  position: absolute;
  top: -2px;
  right: 20%;
  background: linear-gradient(135deg, #ff3b30, #ff9500);
  color: white;
  border-radius: 12px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 2px solid var(--mobile-nav-bg);
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

body.light-mode .mobile-notification-badge {
  border-color: var(--mobile-nav-light-bg);
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.3);
}

/* Menú desplegable para móvil - Diseño integrado con el navbar */
.mobile-dropdown {
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 250px;
  background: rgba(var(--darker-rgb), 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
  z-index: 999;
  transform: translateY(10px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 10px;
  will-change: transform, opacity, visibility;
}

/* Posicionamiento específico para cada dropdown */
#mobile-user-dropdown {
  right: 10px;
  left: auto;
}

#mobile-more-dropdown {
  right: 10px;
  left: auto;
}

body.light-mode .mobile-dropdown {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(var(--primary-rgb), 0.15);
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.15);
}

/* Flecha en la parte inferior del dropdown */
.mobile-dropdown::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 16px;
  height: 16px;
  background: inherit;
  border-right: 1px solid rgba(var(--primary-rgb), 0.3);
  border-bottom: 1px solid rgba(var(--primary-rgb), 0.3);
  transform: rotate(45deg);
}

body.light-mode .mobile-dropdown::after {
  border-right: 1px solid rgba(var(--primary-rgb), 0.15);
  border-bottom: 1px solid rgba(var(--primary-rgb), 0.15);
}

.mobile-dropdown.show,
.mobile-dropdown.active {
  transform: translateY(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.mobile-dropdown-header {
  display: flex;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(var(--light-rgb), 0.1);
  margin-bottom: 0.5rem;
}

body.light-mode .mobile-dropdown-header {
  border-bottom: 1px solid rgba(var(--dark-rgb), 0.1);
}

.mobile-dropdown-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  margin-right: 0.75rem;
  border: 2px solid var(--primary);
}

.mobile-dropdown-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  margin-right: 0.75rem;
}

.mobile-dropdown-user-info {
  flex: 1;
}

.mobile-dropdown-username {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--light);
  margin-bottom: 0.1rem;
}

body.light-mode .mobile-dropdown-username {
  color: var(--dark);
}

.mobile-dropdown-role {
  font-size: 0.7rem;
  color: var(--primary);
}

.mobile-dropdown-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-dropdown-item {
  margin-bottom: 0.5rem;
}

/* Para elementos que deben ocupar todo el ancho */
.mobile-dropdown-item.full-width {
  width: 100%;
}

.mobile-dropdown-link {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 12px;
  color: rgba(var(--light-rgb), 0.9);
  text-decoration: none;
  transition: all 0.2s ease;
  background: rgba(var(--light-rgb), 0.05);
  border: 1px solid rgba(var(--light-rgb), 0.08);
  white-space: nowrap;
}

body.light-mode .mobile-dropdown-link {
  color: rgba(var(--dark-rgb), 0.9);
  background: rgba(var(--dark-rgb), 0.03);
  border: 1px solid rgba(var(--dark-rgb), 0.08);
}

.mobile-dropdown-link:hover,
.mobile-dropdown-link:active {
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary-light);
  transform: translateY(-2px);
}

body.light-mode .mobile-dropdown-link:hover,
body.light-mode .mobile-dropdown-link:active {
  color: var(--primary);
}

.mobile-dropdown-icon {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  font-size: 0.9rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--primary-rgb), 0.15);
  border-radius: 6px;
  padding: 0.4rem;
  transition: all 0.2s ease;
}

.mobile-dropdown-link:hover .mobile-dropdown-icon {
  background: var(--primary);
  color: white;
}

.mobile-dropdown-divider {
  height: 1px;
  background: var(--mobile-nav-border);
  margin: 0.75rem 0;
}

body.light-mode .mobile-dropdown-divider {
  background: var(--mobile-nav-light-border);
}

.mobile-dropdown-logout {
  color: var(--danger);
}

.mobile-dropdown-logout:hover,
.mobile-dropdown-logout:focus {
  background: rgba(var(--danger-rgb), 0.1);
  color: var(--danger);
}

.mobile-dropdown-admin {
  color: var(--warning);
}

.mobile-dropdown-admin:hover,
.mobile-dropdown-admin:focus {
  background: rgba(var(--warning-rgb), 0.1);
  color: var(--warning);
}

/* Overlay para cerrar el menú desplegable */
.mobile-dropdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
}

/* Estilos para el menú móvil expandible - Versión completamente reescrita */
.mobile-menu {
  position: fixed;
  top: 0;
  right: -100%; /* Ocultar completamente fuera de la pantalla */
  width: 300px;
  height: 100%;
  background: rgba(20, 20, 30, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 9999; /* Valor muy alto para asegurar que esté por encima de todo */
  transition: right 0.3s ease;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  overscroll-behavior: contain; /* Prevenir scroll del body */
  -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
}

.mobile-menu.active {
  right: 0;
}

/* Overlay para el menú móvil */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998; /* Justo debajo del menú */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* Prevenir scroll del body cuando el menú está abierto */
body.menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

body.light-mode .mobile-dropdown-overlay {
  background: rgba(0, 0, 0, 0.2);
}

.mobile-dropdown-overlay.show,
.mobile-dropdown-overlay.active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto;
}

/* Animaciones adicionales */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.pulse {
  animation: pulse 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Animación para los dropdowns */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-dropdown.show,
.mobile-dropdown.active {
  animation: fadeInUp 0.2s ease forwards;
}

/* Transición suave para cambio de tema */
.theme-transition {
  transition: background-color 0.5s ease, color 0.5s ease;
}

/* Animación para ocultar/mostrar la barra de navegación */
.mobile-navbar.hidden {
  transform: translateY(100%);
}

.mobile-navbar.animated {
  animation: slideUp 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Botón flotante para menú móvil - Versión mejorada */
.mobile-menu-toggle-floating {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  z-index: 9997; /* Alto pero por debajo del menú y overlay */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-menu-toggle-floating:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.mobile-menu-toggle-floating:active {
  transform: scale(0.95);
}

.mobile-menu-toggle-floating .hamburger-icon {
  width: 24px;
  height: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mobile-menu-toggle-floating .hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: white;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Animación del botón hamburguesa cuando el menú está abierto */
body.menu-open .mobile-menu-toggle-floating .hamburger-icon span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

body.menu-open .mobile-menu-toggle-floating .hamburger-icon span:nth-child(2) {
  opacity: 0;
}

body.menu-open .mobile-menu-toggle-floating .hamburger-icon span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Estilos específicos para la barra de navegación de escritorio */
.navbar-desktop {
  display: flex;
  width: 100%;
}

/* Media queries para mostrar/ocultar navbars según el tamaño de pantalla */
@media (max-width: 991.98px) {
  /* Ocultar completamente la barra de navegación de escritorio */
  .navbar-desktop {
    display: none !important;
  }
  
  .desktop-navbar {
    display: none !important;
  }

  /* Mostrar la barra de navegación móvil */
  .mobile-navbar {
    display: block !important;
  }
}

@media (min-width: 992px) {
  /* Mostrar la barra de navegación de escritorio */
  .navbar-desktop {
    display: flex !important;
  }
  
  /* Ocultar el botón flotante en escritorio */
  .mobile-menu-toggle-floating {
    display: none !important;
  }
}

  /* Añadir padding al final del body para compensar el navbar fijo */
  body {
    padding-bottom: var(--mobile-nav-height) !important;
    padding-top: 0 !important; /* Eliminar cualquier padding superior que pudiera existir */
  }

  /* Ajustar el contenido principal para que no tenga margen superior */
  .main-content,
  .container-fluid,
  .container {
    padding-top: 1rem !important;
  }

  /* Asegurarse de que el navbar móvil esté siempre visible en la parte inferior */
  .mobile-navbar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1030 !important;
  }
}