/* ==========================================================================
   ESTILOS BASE Y VARIABLES EXPANDIDAS
   ========================================================================== */
:root {
  /* Colores principales */
  --primary-color: #4e73df;
  --secondary-color: #2e59d9;
  --accent-color: #f8f9fc;
  --text-dark: #5a5c69;
  --text-light: #858796;
  
  /* Nuevas variables para mejor control */
  --primary-hover: #3a5fc7;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #3b82f6;
  
  /* Espaciado */
  --nav-padding-y: 0.75rem;
  --nav-padding-x: 1.25rem;
  --nav-item-gap: 1rem;
  
  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-nav: 0 0.25rem 1rem rgba(0, 0, 0, 0.08);
  
  /* Transiciones */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.35s ease;
  
  /* Border radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
}

body {
  font-family: 'Poppins', sans-serif;
  color: var(--text-dark);
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* ==========================================================================
   NAVEGACIÓN PRINCIPAL - MEJORADA
   ========================================================================== */

/* Navbar container */
.navbar {
  transition: all var(--transition-slow);
  padding: var(--nav-padding-y) 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background-color: #ffffff !important;
}

/* Sticky behavior mejorado */
.navbar.scrolled {
  padding: 0.5rem 0;
  box-shadow: var(--shadow-nav);
  border-bottom-color: transparent;
}

/* Logo mejorado - SIN BORDES */
.navbar-brand {
  font-weight: 700;
  font-size: 1.45rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  gap: 0.5rem;
  /* CRÍTICO: Eliminar cualquier borde */
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

.navbar-brand:hover {
  transform: scale(1.01);
  opacity: 0.9;
}

.navbar-brand:focus,
.navbar-brand:active {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

.navbar-brand .bi {
  font-size: 1.6rem;
  color: var(--primary-color);
}

.navbar-brand span {
  color: var(--text-dark);
}

.navbar-brand span:last-child {
  color: var(--primary-color);
  font-weight: 700;
}

/* Nav items mejorados */
.navbar-nav {
  gap: var(--nav-item-gap);
}

.navbar-nav .nav-item {
  position: relative;
}

.nav-link {
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
  padding: 0.65rem var(--nav-padding-x);
  color: var(--text-dark);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.15rem;
}

.nav-link i {
  font-size: 1.1rem;
  transition: transform var(--transition-fast);
}

/* Hover state mejorado */
.nav-link:hover {
  background: rgba(78, 115, 223, 0.06);
  color: var(--primary-color);
  transform: translateY(-1px);
}

.nav-link:hover i {
  transform: scale(1.1);
}

/* Active state con underline animado */
.nav-link.active {
  color: var(--primary-color);
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 3px;
  background: var(--primary-color);
  border-radius: 999px;
  animation: underline-grow 0.3s ease;
}

@keyframes underline-grow {
  from {
    width: 0%;
    opacity: 0;
  }
  to {
    width: 50%;
    opacity: 1;
  }
}

/* Hover underline para items no activos */
.nav-link:not(.active):hover::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30%;
  height: 2px;
  background-color: var(--primary-color);
  opacity: 0.5;
  border-radius: 999px;
}

/* ==========================================================================
   DROPDOWN MEJORADO
   ========================================================================== */
.dropdown-menu {
  border: none;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  margin-top: 0.75rem;
  min-width: 220px;
  animation: dropdown-fade var(--transition-fast);
}

@keyframes dropdown-fade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-dark);
  font-weight: 500;
}

.dropdown-item i {
  font-size: 1.15rem;
  width: 24px;
  flex-shrink: 0;
}

.dropdown-item:hover {
  background: #f8f9fa;
  color: var(--primary-color);
  padding-left: 1.25rem;
  transform: translateX(2px);
}

.dropdown-item:active {
  background: rgba(78, 115, 223, 0.1);
  color: var(--primary-color);
}

/* Divider en dropdown */
.dropdown-divider {
  margin: 0.5rem 0;
  border-color: #e9ecef;
}

/* Header del dropdown (para info de usuario) */
.dropdown-menu li:first-child {
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   AVATAR Y USUARIO MEJORADO
   ========================================================================== */
.user-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e9ecef;
  transition: all var(--transition-fast);
}

.dropdown-toggle:hover .user-avatar {
  border-color: var(--primary-color);
  transform: scale(1.05);
}

/* Dot de estado online */
.user-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: var(--success-color);
  border: 2px solid white;
  border-radius: 50%;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.2;
}

/* ==========================================================================
   BOTONES CTA MEJORADOS
   ========================================================================== */
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 8px rgba(78, 115, 223, 0.15);
}

.btn-primary:hover {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78, 115, 223, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline-primary {
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-width: 2px;
}

.btn-outline-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(78, 115, 223, 0.2);
}

/* Espaciado entre CTAs */
.navbar .d-flex.align-items-center {
  gap: 0.75rem !important;
}

/* ==========================================================================
   NOTIFICACIONES
   ========================================================================== */
.notification-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  color: #6b7280;
  transition: all var(--transition-fast);
  border: none;
  text-decoration: none;
  position: relative;
}

.notification-btn:hover {
  background: #e9ecef;
  color: var(--primary-color);
  transform: scale(1.05);
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--danger-color);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  animation: pulse-badge 2s ease-in-out infinite;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ==========================================================================
   BADGES EN NAV
   ========================================================================== */
.nav-sub-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  line-height: 1;
  font-size: 0.82rem;
  padding: 0.45rem 0.65rem !important;
  border-radius: 999px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   MODALES Y CARDS DE ÁREAS
   ========================================================================== */
.category-tabs .nav-link {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.category-tabs .nav-link:hover {
  background-color: rgba(13, 110, 253, 0.1);
}

.category-tabs .nav-link.active {
  background-color: #0d6efd;
  color: #fff !important;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.area-card {
  border-radius: 14px;
  border: 1px solid #e7e7e7;
  background: #fff;
  padding: 18px;
  transition: all var(--transition-normal);
  height: 100%;
  cursor: pointer;
}

.area-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: var(--primary-color);
}

.area-icon {
  font-size: 38px;
  color: #0d6efd;
  transition: transform var(--transition-fast);
}

.area-card:hover .area-icon {
  transform: scale(1.1);
}

.badge-popular {
  font-size: 1.2rem;
  color: #f97316;
}

.badge-just {
  background: #22c55e !important;
  color: white;
  font-size: 0.75rem;
  margin-top: 8px;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
}

.badge-nojust {
  background: #6c757d !important;
  color: white;
  font-size: 0.75rem;
  margin-top: 8px;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   CONFIGURACIÓN ESPECÍFICA PARA MÓVIL (MODO APP)
   ========================================================================== */
@media (max-width: 991.98px) {

  html, body {
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
  }

  .section-subtitle, .module-card__title, p, span:not(.bi), .text-secondary {
    -webkit-user-select: text;
    user-select: text;
  }

  main {
    padding-bottom: 100px !important;
  }

  /* BARRA INFERIOR MÓVIL - MEJORADA */
  .bottom-nav-wrapper {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 75px !important;
    background-color: #ffffff !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15) !important;
    z-index: 10000 !important;
    display: flex !important;
    align-items: center;
    border-top: 1px solid #e9ecef !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .bottom-nav-wrapper .d-flex {
    width: 100%;
  }

  .nav-item-mobile {
    flex: 1;
    text-align: center;
    color: #858796 !important;
    text-decoration: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px;
    padding: 0.5rem 0.25rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    position: relative;
  }

  .nav-item-mobile i {
    font-size: 1.4rem !important;
    display: block !important;
    transition: all var(--transition-fast);
  }

  .nav-item-mobile span {
    font-size: 0.68rem !important;
    font-weight: 500;
    display: block !important;
    transition: all var(--transition-fast);
  }

  /* Active state mejorado en móvil */
  .nav-item-mobile.active {
    color: var(--primary-color) !important;
  }

  .nav-item-mobile.active i {
    transform: scale(1.15);
  }

  .nav-item-mobile.active span {
    font-weight: 700;
  }

  /* Indicador activo */
  .nav-item-mobile.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 0 0 999px 999px;
  }

  .navbar-toggler {
    display: none !important;
  }

  .navbar-brand {
    font-size: 1.25rem;
  }

  /* Nav items en móvil */
  .navbar-nav {
    gap: 0;
  }

  .navbar-nav .nav-link {
    padding: 0.8rem 1rem;
    margin: 0.2rem 0;
  }

  /* Dropdown en móvil */
  .dropdown-menu {
    border: none;
    box-shadow: none;
    padding-left: 1rem;
    margin-top: 0;
  }

  .dropdown-item {
    padding: 0.6rem 0.8rem;
  }
}

/* ==========================================================================
   CONFIGURACIÓN ESPECÍFICA PARA ESCRITORIO
   ========================================================================== */
@media (min-width: 992px) {

  .bottom-nav-wrapper {
    display: none !important;
  }

  .category-nav-wrapper .d-flex {
    overflow: visible !important;
    flex-wrap: wrap !important;
  }

  .category-nav-wrapper {
    margin: 0;
    padding: 0;
  }

  .category-nav-wrapper .btn {
    transition: all var(--transition-fast);
    border-width: 2px;
  }

  .category-nav-wrapper .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(78, 115, 223, 0.2) !important;
  }

  html, body {
    -webkit-user-select: auto;
    user-select: auto;
  }

  /* Ajustes del nav en desktop */
  .navbar-collapse {
    align-items: center;
  }

  .navbar-nav {
    align-items: center;
  }
}

/* ==========================================================================
   ESTILOS ESPECIALES Y OPTIMIZACIONES
   ========================================================================== */
body.is-app.page-login .navbar,
body.is-app.page-login footer {
  display: none !important;
}

.page-login main {
  padding-bottom: 100px !important;
}

/* WhatsApp float mejorado */
.whatsapp-float {
  position: fixed;
  bottom: 85px;
  right: 25px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #fff;
  border-radius: 50%;
  z-index: 9999;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
  transition: all var(--transition-fast);
  animation: float-pulse 3s ease-in-out infinite;
}

.whatsapp-float:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.6);
}

@keyframes float-pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Cards Detalle Asignatura mejorados */
.item-anio-card, .module-card-hover {
  transition: all var(--transition-normal);
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  border-radius: var(--radius-md);
}

.item-anio-card:hover, .module-card-hover:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg) !important;
  border-color: var(--primary-color) !important;
}

/* Scrollbar personalizado (opcional - más moderno) */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Si prefieres scrollbar invisible */
.custom-scrollbar-hidden::-webkit-scrollbar { 
  display: none; 
}

.custom-scrollbar-hidden {
  -ms-overflow-style: none;
  scrollbar-width: none;
  overflow-x: auto;
}

.breadcrumb-item+.breadcrumb-item::before {
  content: "›";
  font-weight: 600;
}

/* Ajuste para pantallas muy pequeñas */
@media (max-width: 375px) {
  .row-cols-2>.col { 
    width: 100%; 
  }
  
  .navbar-brand {
    font-size: 1.1rem;
  }
}

/* Estados de batch */
.batch-status-saving {
  border-color: #3b82f6 !important;
  color: #1e40af;
  background: #dbeafe !important;
  transition: all var(--transition-fast);
}

.batch-status-success {
  border-color: #16a34a !important;
  color: #14532d;
  background: #dcfce7 !important;
  transition: all var(--transition-fast);
}

.batch-status-error {
  border-color: #dc2626 !important;
  color: #991b1b;
  background: #fee2e2 !important;
  transition: all var(--transition-fast);
}

/* ==========================================================================
   MEJORAS DE ACCESIBILIDAD
   ========================================================================== */

/* Focus visible para navegación por teclado */
.nav-link:focus-visible,
.btn:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   MEJORAS ADICIONALES PARA INDEX.PHP
   ========================================================================== */

/* Hero title más profesional */
.display-5 {
  color: #2c5aa0;
  font-weight: 700;
  line-height: 1.2;
}

/* Subtítulos más legibles */
.fs-5 {
  color: #5a5c69;
  line-height: 1.6;
}

/* Section titles */
.section-title {
  font-weight: 700;
  line-height: 1.15;
  color: #2c5aa0;
}

.section-subtitle {
  color: #6b7280;
  font-size: 1.1rem;
  line-height: 1.5;
}