/* ===== RESET Y ESTILOS GENERALES ===== */
.bi {
  vertical-align: -.125em;
  pointer-events: none;
  fill: currentColor;
}

.dropdown-toggle { outline: 0; }

.nav-flush .nav-link {
  border-radius: 0;
}

.btn-toggle {
  display: inline-flex;
  align-items: center;
  padding: .25rem .5rem;
  font-weight: 600;
  color: var(--bs-body-color);
  background-color: transparent;
  border: 0;
}

.btn-toggle:hover,
.btn-toggle:focus {
  color: var(--bs-primary);
  background-color: var(--bs-card-bg);
}

.btn-toggle::before {
  width: 1.25em;
  line-height: 0;
  content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e");
  transition: transform .35s ease;
  transform-origin: .5em 50%;
  opacity: 0.85;
}

.btn-toggle[aria-expanded="true"] {
  color: var(--bs-body-color);
}

.btn-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
  color: var(--bs-primary);
}

.btn-toggle-nav a {
  display: inline-flex;
  padding: .1875rem .5rem;
  margin-top: .125rem;
  margin-left: 1.25rem;
  text-decoration: none;
  color: var(--bs-body-color);
}

.btn-toggle-nav a:hover,
.btn-toggle-nav a:focus {
  color: var(--bs-primary);
  background-color: var(--bs-card-bg);
}

.scrollarea {
  overflow-y: auto;
}

.fw-semibold { font-weight: 600; }
.lh-tight { line-height: 1.25; }

/* ===== ESTILOS PRINCIPALES DEL SIDEBAR ===== */
#sidebarMenu {
  transition: all 0.3s ease;
  height: calc(100vh - 56px); /* Altura completa menos header */
  position: fixed;
  top: 56px;
  left: 0;
  z-index: 1000;
  overflow-y: auto;
}

/* ===== ESTILOS PARA MOBILE Y TABLET ===== */
@media (max-width: 991.98px) {
  #sidebarMenu {
    width: 280px;
    transform: translateX(-100%);
  }
  
  #sidebarMenu.sidebar-show {
    transform: translateX(0);
    box-shadow: 3px 0 10px rgba(0, 0, 0, 0.1);
  }
  
  .sidebar-toggle {
    display: none;
  }
  
  /* Ajuste para el contenido principal */
  #sidebarMenu.sidebar-show + main {
    transform: translateX(280px);
    width: calc(100% - 280px);
    overflow-x: hidden;
    position: fixed;
    right: 0;
  }
  
  /* Ajuste para landscape */
  @media (orientation: landscape) {
    #sidebarMenu {
      width: 250px;
    }
    
    #sidebarMenu.sidebar-show + main {
      transform: translateX(250px);
      width: calc(100% - 250px);
    }
  }
  
  /* Ajuste específico para Galaxy S20 landscape */
  @media (max-width: 915px) and (max-height: 414px) and (orientation: landscape) {
    #sidebarMenu {
      width: 220px;
    }
    
    #sidebarMenu.sidebar-show + main {
      transform: translateX(220px);
      width: calc(100% - 220px);
    }
  }
}

/* ===== ESTILOS PARA DESKTOP ===== */
@media (min-width: 992px) {
  #sidebarMenu {
    position: relative;
    top: 0;
    height: calc(100vh - 56px);
    transform: none !important;
    box-shadow: none;
    width: 100%;
  }
  
  #sidebarMenu.sidebar-collapsed {
    transform: translateX(-100%) !important;
    position: absolute;
  }
  
  #sidebarMenu.sidebar-show + main {
    transform: none !important;
    width: auto !important;
    position: static !important;
  }
  
  .main-expanded {
    margin-left: 0 !important;
    width: 100% !important;
  }
  
  .sidebar-toggle {
    position: fixed;
    left: calc(16.666% - 12px);
    top: 70px;
    width: 24px;
    height: 24px;
    background: var(--bs-card-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
  }
  
  .sidebar-toggle .material-symbols-outlined {
    font-size: 16px;
    color: #495057;
  }
  
  .sidebar-collapsed ~ .sidebar-toggle {
    left: 0;
    transform: rotate(180deg);
  }
}

/* ===== ESTILOS PARA EL BOTÓN HAMBURGUESA ===== */
.navbar-toggler {
  display: block;
  position: absolute;
  right: 0;
  margin-right: 1rem;
}

@media (min-width: 992px) {
  .navbar-toggler {
    display: none;
  }
}


/* ===== CORRECCIÓN ESPECÍFICA PARA SAMSUNG S20 LANDSCAPE ===== */
@media (max-width: 915px) and (max-height: 414px) and (orientation: landscape) {
  /* Cuando el sidebar está oculto */
  #sidebarMenu:not(.sidebar-show) + main {
    transform: translateX(0) !important;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    position: static !important;
    margin-left: 0 !important;
    overflow-x: visible !important;
  }

  /* Cuando el sidebar está visible */
  #sidebarMenu.sidebar-show + main {
    transform: translateX(220px) !important;
    width: calc(100% - 220px) !important;
    left: auto !important;
    right: 0 !important;
    position: fixed !important;
    overflow-x: hidden !important;
  }
}

/* Ajuste adicional para resoluciones específicas de Galaxy S20 */
@media (width: 800px) and (height: 360px) and (orientation: landscape) {
  #sidebarMenu {
    max-width: 220px;
  }

  #sidebarMenu.sidebar-show + main {
    transform: translateX(220px) !important;
    width: calc(100% - 220px) !important;
  }

  /* Corrección para el hueco residual */
  body {
    overflow-x: hidden;
  }

  .container-fluid {
    padding-right: 0 !important;
    padding-left: 0 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
  }

  /* Ajuste fino del contenido principal */
  main {
    min-width: 100vw !important;
    max-width: 100vw !important;
    padding-right: 15px !important;
    padding-left: 15px !important;
  }

  /* Cuando el sidebar está oculto */
  #sidebarMenu:not(.sidebar-show) + main {
    min-width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
    position: relative !important;
    margin-left: 0 !important;
    left: 0 !important;
  }
}

/* Corrección para el hueco en dispositivos móviles landscape */
@media (max-width: 991.98px) and (orientation: landscape) {
  #sidebarMenu:not(.sidebar-show) + main {
    margin-left: 0 !important;
    width: 100% !important;
    transform: none !important;
    position: static !important;
  }
}

/* Ajuste específico para iPhone SE */
@media (max-width: 375px) and (max-height: 667px) {
  .navbar-toggler {
    z-index: 1040;
  }
  
  #sidebarMenu {
    width: 260px;
    z-index: 1030;
  }
  
  #sidebarMenu.sidebar-show {
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
  }
}

/* ===== SOLUCIÓN UNIVERSAL PARA EL PROBLEMA DEL HUECO ===== */
@media (max-width: 991.98px) {
  /* Reset completo cuando el sidebar está oculto */
  #sidebarMenu:not(.sidebar-show) + main {
    margin-left: 0 !important;
    width: 100% !important;
    transform: none !important;
    position: static !important;
    left: 0 !important;
    right: 0 !important;
    padding-right: 15px !important;
    padding-left: 15px !important;
    overflow-x: hidden !important;
  }
  
  /* Ajuste cuando el sidebar está visible */
  #sidebarMenu.sidebar-show + main {
    overflow-x: hidden;
    position: relative;
  }
  
  /* Corrección especial para dispositivos problemáticos */
  @media (max-height: 430px) {
    #sidebarMenu {
      width: 220px;
    }
    #sidebarMenu.sidebar-show + main {
      transform: translateX(220px) !important;
      width: calc(100% - 220px) !important;
    }
  }
}

/* ===== CORRECCIÓN PARA IPHONE SE ===== */
@media (max-width: 375px) and (max-height: 667px) {
  #sidebarMenu {
    z-index: 1030;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3);
  }
  .navbar-toggler {
    z-index: 1040;
  }
}


/* Añade esto al final de tu CSS */
@media (min-width: 1920px) {
  /* Sidebar */
  #sidebarMenu {
    width: 350px !important; /* Más ancho para pantallas grandes */
  }

  /* Contenido principal */
  #sidebarMenu:not(.sidebar-collapsed) + main {
    margin-left: 350px !important;
  }

  /* Botones y texto */
  .btn-toggle, .btn-toggle-nav a {
    font-size: 1.2rem !important; /* Texto más legible */
    padding: 0.5rem 1rem !important;
  }

  /* Iconos */
  .material-symbols-outlined {
    font-size: 2rem !important; /* Íconos más grandes */
  }

  /* Header */
  header.navbar {
    height: 80px !important; /* Más alto para mejor usabilidad */
  }
}

/* Para TVs 4K/8K (3840px en adelante) */
@media (min-width: 3840px) {
  #sidebarMenu {
    width: 500px !important;
  }
  #sidebarMenu:not(.sidebar-collapsed) + main {
    margin-left: 500px !important;
  }
  body {
    font-size: 1.5rem !important; /* Escala todo el texto */
  }
}

/* ===== ESTILOS MODERNOS DEL SIDEBAR ===== */
.sidebar {
  background-color: var(--bs-sidebar-bg);
  color: var(--bs-body-color);
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
  border-right: 1px solid var(--bs-border-color);
}

.sidebar-header {
  background-color: var(--bs-navbar-bg);
  border-bottom: 1px solid var(--bs-border-color);
  padding: 1.5rem 1rem 1rem;
  border-radius: 0 0 0.5rem 0.5rem;
}

.sidebar-brand-icon {
  color: var(--bs-primary);
}

.sidebar-brand-title {
  color: var(--bs-body-color);
  font-weight: 600;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
}

.sidebar-menu {
  padding-left: 0;
  margin-bottom: 0;
}

.sidebar-section {
  margin-bottom: 1rem;
}

.sidebar-section-header {
  margin-bottom: 0.5rem;
}

.sidebar-section-title {
  color: var(--bs-body-color);
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  background-color: rgba(0, 0, 0, 0.02);
  border: 1px solid transparent;
}

.sidebar-section-title:hover {
  background-color: var(--bs-card-bg);
  color: var(--bs-primary);
  text-decoration: none;
  border-color: var(--bs-border-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sidebar-section-title[aria-expanded="true"] .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-chevron {
  transition: transform 0.3s ease;
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

.sidebar-submenu {
  padding-left: 1.5rem;
}

.sidebar-item {
  margin-bottom: 0.25rem;
}

.sidebar-link {
  color: var(--bs-body-color);
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link:focus {
  background-color: var(--bs-card-bg);
  color: var(--bs-primary);
  text-decoration: none;
}

.sidebar-link.active {
  background-color: var(--bs-primary);
  color: white;
}

.sidebar-link i {
  width: 1.5rem;
  text-align: center;
}

.sidebar-divider {
  height: 1px;
  background-color: var(--bs-border-color);
  margin: 0.75rem 0;
  opacity: 0.5;
}

.sidebar-theme-selector {
  background-color: var(--bs-card-bg);
  border: 1px solid var(--bs-border-color);
}

/* Ajustes para el tema oscuro */
[data-bs-theme="dark"] .sidebar-section-title:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Ajustes responsivos */
@media (max-width: 991.98px) {
  .sidebar {
    width: 280px;
  }
  
  .sidebar-header {
    padding: 1rem;
  }
  
  .sidebar-content {
    padding: 0.75rem;
  }
}

@media (min-width: 992px) {
  .sidebar {
    width: 100%;
    height: calc(100vh - 56px);
  }
  
  .sidebar-header {
    padding: 1.5rem 1rem 1rem;
  }
  
  .sidebar-content {
    padding: 1rem;
  }
}

/* Ajustes para el toggle del sidebar */
.sidebar-toggle {
  position: fixed;
  left: calc(16.666% - 12px);
  top: 70px;
  width: 24px;
  height: 24px;
  background: var(--bs-card-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.sidebar-collapsed ~ .sidebar-toggle {
  left: 0;
  transform: rotate(180deg);
}

/* ===== MEJORAS DE DISEÑO DEL SIDEBAR ===== */

/* Mejoras en las secciones del sidebar */
.sidebar-section {
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.02));
  border-radius: 0.75rem;
  padding: 0.5rem;
  transition: all 0.3s ease;
}

.sidebar-section:hover {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.04));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Mejoras en los enlaces */
.sidebar-link {
  position: relative;
  overflow: hidden;
  border-left: 3px solid transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-link:hover {
  border-left-color: var(--bs-primary);
  padding-left: 1rem;
  transform: translateX(4px);
}

.sidebar-link.active {
  border-left-color: var(--bs-primary);
  background: linear-gradient(135deg, var(--bs-primary), var(--mdc-primary-variant));
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25);
}

/* Indicador de estado activo */
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background-color: white;
  border-radius: 0 2px 2px 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

/* Mejoras en los iconos */
.sidebar-link i {
  transition: all 0.3s ease;
  font-size: 1.1em;
}

.sidebar-link:hover i {
  transform: scale(1.2);
  color: var(--bs-primary);
}

/* Mejoras en el header del sidebar */
.sidebar-header {
  background: linear-gradient(135deg, var(--bs-navbar-bg), rgba(13, 110, 253, 0.1));
  position: relative;
  overflow: hidden;
}

.sidebar-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--bs-primary), var(--bs-info), var(--bs-success));
  opacity: 0.7;
}

/* Mejoras en el selector de tema */
.sidebar-theme-selector {
  backdrop-filter: blur(10px);
  background-color: rgba(var(--bs-card-bg-rgb, 255, 255, 255), 0.8);
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.sidebar-theme-selector:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* Scrollbar personalizado */
.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
  background-color: var(--bs-border-color);
  border-radius: 3px;
  transition: background-color 0.3s;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background-color: var(--bs-primary);
}

/* Efectos de carga suave */
.sidebar {
  animation: fadeInSidebar 0.5s ease-out;
}

@keyframes fadeInSidebar {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Responsive improvements */
@media (max-width: 768px) {
  .sidebar-section {
    padding: 0.375rem;
  }
  
  .sidebar-link {
    padding: 0.625rem 0.875rem;
  }
  
  .sidebar-link:hover {
    padding-left: 1.125rem;
  }
}

/* Dark mode enhancements */
[data-bs-theme="dark"] .sidebar-section {
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.02));
}

[data-bs-theme="dark"] .sidebar-section:hover {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.05));
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .sidebar-theme-selector {
  background-color: rgba(var(--bs-card-bg-rgb, 30, 41, 59), 0.8);
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .sidebar-section,
  .sidebar-link,
  .sidebar-theme-selector {
    transition: none;
    animation: none;
  }
  
  .sidebar-link:hover {
    transform: none;
  }
  
  .sidebar-link.active::before {
    animation: none;
  }
}