/* ===== MENÚ LATERAL ===== */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background-color: #f8f9fb;
  color: #1f2937;
  box-shadow: 2px 0 5px rgba(0,0,0,0.2);
  padding: 1rem;
  overflow-y: auto;
  z-index: 1000;
  transition: left 0.3s ease, width 0.3s ease;
}

#sidebar.collapsed {
  width: 60px;
  overflow-x: hidden;
}
#sidebar.collapsed h2,
#sidebar.collapsed .menu-item-header span,
#sidebar.collapsed .submenu,
#sidebar.collapsed .submenu-arrow {
  display: none;
}

/* CABECERA */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25rem;
  color: #1f2937;
}

.toggle-menu-btn {
  font-size: 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
}

/* TITULOS DE SECCIÓN */
.menu-section-title {
  margin: 1rem 0 0.25rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: bold;
  color: #4b5563;
  text-transform: uppercase;
}

/* LISTA BASE */
#sidebar ul,
#sidebar .submenu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ITEM PRINCIPAL */
.menu-item-header {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
  color: #1f2937;
  position: relative;
}

.menu-item-header:hover {
  background-color: #e5e7eb;
}

.menu-item-header.active {
  background-color: #3b82f6;
  color: #fff;
}

.menu-item-header.active .menu-icon {
  color: #fff;
}

/* ÍCONOS */
.menu-icon {
  width: 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 1rem;
  transition: color 0.2s ease;
  flex-shrink: 0;
  margin-right: 0.75rem;
}

.menu-item-header:hover .menu-icon {
  color: #3b82f6;
}

/* FLECHITA SUBMENÚ */
.submenu-arrow {
  transition: transform 0.2s ease, color 0.2s ease;
  font-size: 0.85rem;
  color: #6b7280;
  margin-left: auto;
  flex-shrink: 0;
}

/* SUBMENÚS */
.submenu {
  display: none;
}

.submenu.expanded {
  display: block;
}

/* ALINEACIÓN JERÁRQUICA CON LÍNEAS VERTICALES */
.menu-item-header {
  padding-left: 0.75rem !important;
}

.submenu .menu-item-header {
  padding-left: 1.5rem !important;
  position: relative;
}

.submenu .submenu .menu-item-header {
  padding-left: 2.25rem !important;
}

.submenu .submenu .submenu .menu-item-header {
  padding-left: 3rem !important;
}

/* LÍNEAS VERTICALES PARA JERARQUÍA */
.submenu {
  position: relative;
}

.submenu::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: #d1d5db;
}

.submenu .submenu::before {
  left: 1.5rem;
}

.submenu .submenu .submenu::before {
  left: 2.25rem;
}

/* ENLACES COMO ITEMS */
#sidebar a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 0.5rem 0;
  border-radius: 6px;
  transition: background 0.2s ease;
  padding-left: 0.75rem !important;
}
#sidebar a:hover {
  background-color: #e5e7eb;
}
#sidebar a.active {
  background-color: #3b82f6;
  color: #fff;
}

/* AJUSTE DEL MAIN-CONTENT */
#main-content {
  margin-left: 220px;
  padding: 1.5rem;
  transition: margin-left 0.3s ease;
}

#main-content.expanded {
  margin-left: 60px;
}
