/* Estilos Generales del Body */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  /* USO: Fondo principal */
  background: #f8f8f8;
  /* USO: Texto primario */
  color: #333333;
  box-sizing: border-box;
  padding-top: 60px; /* Espacio para la barra de herramientas fija */
}

/* Estilos específicos para el body de la página de inicio de sesión para centrar el contenido */
.login-body {
  display: grid;
  place-items: center;
  padding-top: 0; /* Anula el padding para la página de inicio de sesión */
}

/* Oculta visualmente elementos pero los mantiene accesibles para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Contenedor de Inicio de Sesión */
.login-container {
  /* Usando blanco para contraste con el fondo principal */
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
  /* USO: Bordes */
  border: 1px solid #e0e0e0;
  padding: 2rem 3rem;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
  margin: 1rem;
}

.login-form h1 {
  /* USO: Texto primario */
  color: #333333;
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2.5rem;
  font-weight: 600;
}

.input-group {
  margin-bottom: 1.5rem;
}

.input-group input {
  width: 100%;
  padding: 1rem;
  /* USO: Bordes */
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  /* Fondo blanco para campos de entrada */
  background-color: #ffffff;
  /* USO: Texto primario */
  color: #333333;
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 0.3s, background-color 0.3s;
}

.input-group input::placeholder {
  /* USO: Texto secundario */
  color: #666666;
}

.input-group input:focus {
  outline: none;
  /* USO: Acento principal */
  border-color: #ff8000;
  background-color: #ffffff;
}

.login-form button {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 8px;
  /* USO: Acento principal y botones de acción */
  background-color: #ff8000;
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
}

.login-form button:hover {
  background-color: #e67300; /* Tono más oscuro de naranja para hover */
  transform: translateY(-2px);
}

.login-form button:active {
  transform: translateY(0);
}

.message {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    min-height: 24px;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid transparent;
    display: none; /* Hide by default */
    text-align: left;
    color: #c62828; /* Red for errors */
    background-color: #ffcdd2; /* Light red background */
    border-color: #ef9a9a; /* Softer red border */
}

.message.success {
    color: #2e7d32; /* Green for success */
    background-color: #c8e6c9; /* Light green */
    border-color: #a5d6a7; /* Softer green */
}

.message.visible {
    display: block;
    animation: fadeInContent 0.3s ease-in-out;
}

/* Estilos de la barra de herramientas superior */
.top-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    /* USO: Bordes */
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toolbar-nav {
    display: flex;
    gap: 0.5rem;
}

.toolbar-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    /* USO: Texto secundario e iconos */
    color: #666666;
    background-color: transparent;
    transition: background-color 0.2s, color 0.2s;
    text-decoration: none;
}

.toolbar-nav-item:hover {
    /* USO: Fondo principal */
    background-color: #f8f8f8;
    color: #333333;
}

.toolbar-nav-item.active {
    /* USO: Acento principal */
    color: #ff8000;
}

.toolbar-nav-item .icon {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
}

.toolbar-nav-item .tooltip {
    position: absolute;
    top: calc(100% + 8px);
    /* USO: Texto primario */
    background-color: #333333;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1001;
}

.toolbar-nav-item:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.top-toolbar .sidebar-toggle:hover {
    /* USO: Fondo principal */
    background-color: #f8f8f8;
}

.top-toolbar .sidebar-toggle .icon {
    /* USO: Texto secundario e iconos */
    color: #666666;
}

/* Estilos del Panel de Control */
.dashboard-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  width: 100%;
  height: calc(100vh - 60px);
  transition: grid-template-columns 0.3s ease-in-out;
}

.sidebar {
  background: #ffffff;
  /* USO: Bordes */
  border-right: 1px solid #e0e0e0;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  /* USO: Texto primario */
  color: #333333;
  overflow: hidden;
  position: relative;
}

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0; /* Fix for flexbox scrolling issues */
}

.sidebar-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
}

.sidebar-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  /* USO: Texto primario */
  color: #333333;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.sidebar-toggle:hover {
    /* USO: Fondo principal */
    background-color: #f8f8f8;
}

.sidebar-toggle .icon {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    /* USO: Texto secundario e iconos */
    color: #666666;
}

#open-sidebar-btn {
    display: none;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar nav a, .sidebar nav summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem;
  /* USO: Acento principal (texto) y Fondo principal (fondo) */
  color: #ff8000;
  background-color: #f8f8f8;
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  transition: background-color 0.3s, color 0.3s;
  font-weight: 500;
}

.sidebar nav a:hover, 
.sidebar nav li a.active, 
.sidebar .menu-item-collapsible[open] > summary,
.sidebar .menu-item-collapsible summary:hover {
  /* Al seleccionar/pasar el cursor, se mantiene el fondo pero cambia el color del texto y del icono */
  background-color: #f8f8f8;
  /* USO: Texto secundario e iconos */
  color: #666666;
}

.sidebar nav a:hover .icon, 
.sidebar nav li a.active .icon, 
.sidebar .menu-item-collapsible[open] > summary .icon,
.sidebar .menu-item-collapsible summary:hover .icon {
    /* USO: Texto secundario e iconos */
    color: #666666;
}

.sidebar .menu-item-collapsible summary {
  cursor: pointer;
  position: relative;
  list-style: none;
}

.sidebar .menu-item-collapsible summary::after {
  content: '▶';
  font-size: 0.7em;
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.2s;
}

.sidebar .menu-item-collapsible[open] > summary::after {
    transform: translateY(-50%) rotate(90deg);
}

.sidebar .menu-item-collapsible .submenu {
  list-style: none;
  padding: 0.5rem 0 0 1rem;
  margin: 0;
}

.sidebar .menu-item-collapsible .submenu a {
  font-size: 0.95rem;
  padding-left: 3rem;
}

.sidebar .menu-item-collapsible .submenu a .icon {
    display: none;
}

.sidebar .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    /* USO: Acento principal y botones de acción */
    color: #ff8000;
    transition: color 0.3s;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0;
    display: flex;
    justify-content: center;
}

.logout-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background-color: transparent;
    color: #666666;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.logout-button:hover {
  background-color: #f8f8f8;
  color: #ff8000;
}

.logout-button:active {
    transform: scale(0.95);
}

.logout-button .icon {
    width: 24px;
    height: 24px;
}

.logout-button .tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #333333;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1001;
}

.logout-button:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

.main-content {
  padding: 2rem 3rem;
  overflow-y: auto;
  /* USO: Fondo principal */
  background: #f8f8f8;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-header h1 {
  /* USO: Texto primario */
  color: #333333;
  font-size: 2.5rem;
  margin: 0;
  text-shadow: none;
}

.btn-primary {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    /* USO: Acento principal */
    background-color: #ff8000;
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.btn-primary:hover {
    background-color: #e67300; /* Tono más oscuro de naranja para hover */
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}


.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.5rem;
  /* USO: Texto primario */
  color: #333333;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  /* USO: Bordes */
  border: 1px solid #e0e0e0;
  transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-5px);
}

.card h3 {
  margin-top: 0;
  font-size: 1.1rem;
  font-weight: 500;
  /* USO: Texto secundario */
  color: #666666;
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 2.2rem;
  font-weight: bold;
  margin: 0;
  /* USO: Texto primario */
  color: #333333;
}

/* Estilos de la Tabla de Gestión de Usuarios */
.content-table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 0.9em;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    background-color: #ffffff;
}

.content-table thead tr {
    /* USO: Fondo principal */
    background-color: #f8f8f8;
    color: #333333;
    text-align: left;
    font-weight: 600;
    /* USO: Bordes */
    border-bottom: 2px solid #e0e0e0;
}

.content-table th,
.content-table td {
    padding: 12px 15px;
}

.content-table tbody tr {
    /* USO: Bordes */
    border-bottom: 1px solid #e0e0e0;
}

.content-table tbody tr:last-of-type {
    border-bottom: none;
}

.content-table td.action-cell {
    display: flex;
    gap: 8px;
    width: 1%;
    white-space: nowrap;
}

.action-btn {
    padding: 0;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    /* USO: Texto secundario e iconos */
    color: #666666;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.action-btn:hover {
    transform: scale(1.1);
    /* USO: Acento principal */
    color: #ff8000;
    background-color: rgba(255, 128, 0, 0.1);
}

.action-btn .icon {
    width: 18px;
    height: 18px;
}

/* --- Estilos de Pestañas Mejorados --- */
.tabs {
    display: flex;
    /* USO: Bordes */
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-link {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 1rem;
    font-weight: 500;
    /* USO: Texto secundario */
    color: #666666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.3s, border-color 0.3s, background-color 0.2s;
}

.tab-link:hover {
    /* USO: Texto primario */
    color: #333333;
    background-color: #f8f8f8;
}

.tab-link.active {
    /* USO: Acento principal */
    color: #ff8000;
    border-color: #ff8000;
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInContent 0.5s ease;
}

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

/* --- Nuevos Estilos para Formulario de Usuario --- */
.user-form {
    background-color: #ffffff;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    /* USO: Bordes */
    border: 1px solid #e0e0e0;
    max-width: 900px;
    margin: 1rem auto;
}

.user-form .input-group label,
.assignment-form .input-group label,
.options-assignment-container .input-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
    /* USO: Texto primario */
    color: #333333;
}

.user-form .input-group input,
.user-form .input-group select,
.assignment-form .input-group select,
.options-assignment-container .input-group select,
.panel-form .input-group input,
.panel-form .input-group select {
    width: 100%;
    padding: 1rem;
    /* USO: Bordes */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #ffffff;
    /* USO: Texto primario */
    color: #333333;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.3s, background-color 0.3s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.user-form .input-group select,
.assignment-form .input-group select,
.options-assignment-container .input-group select,
.panel-form .input-group select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23333333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}


.user-form .input-group input:focus,
.user-form .input-group select:focus,
.assignment-form .input-group select:focus,
.options-assignment-container .input-group select:focus,
.panel-form .input-group input:focus,
.panel-form .input-group select:focus {
    outline: none;
    /* USO: Acento principal */
    border-color: #ff8000;
}

.user-form .btn-primary {
    width: auto;
    padding: 0.8rem 2rem;
}

/* Estructura de dos columnas para formularios */
.form-grid-columns {
    display: grid;
    /* Crea columnas que se ajustan automáticamente. Cada columna tendrá un mínimo de 300px. */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
}

.form-column h3 {
    font-size: 1.2rem;
    font-weight: 600;
    /* USO: Texto primario */
    color: #333333;
    /* USO: Bordes */
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.75rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.form-actions {
    margin-top: 2rem;
    text-align: right;
}

/* --- Estilos para Validación en Tiempo Real --- */
.validation-message {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    min-height: 1.2rem; /* Reserva espacio para evitar saltos de layout */
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s;
}

.validation-message.available {
    color: #2e7d32; /* Verde */
}

.validation-message.taken {
    color: #c62828; /* Rojo */
}

.validation-message.checking {
    color: #666666; /* Color de texto secundario */
}

.validation-message .spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: #ff8000; /* Color de acento */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* --- Estilos para el Formulario de Entidad --- */
.logo-preview-container {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    border: 2px dashed #e0e0e0;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f8f8f8;
}

.logo-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-input-custom {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

.file-input-label {
    display: inline-block;
    cursor: pointer;
}

/* --- Nuevos Estilos para Asignación de Perfiles --- */
.assignment-form .input-group {
    margin-bottom: 2rem;
}

.assignment-form .btn-primary {
    width: auto;
    padding: 0.8rem 2rem;
    margin-top: 1.5rem;
}

.assignment-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1.5rem;
    background-color: #ffffff;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
}

.profile-panel {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    background-color: #fdfdfd;
}

.profile-panel h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: #333333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.75rem;
}

.profile-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
}

.profile-list li {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.profile-list li:last-child {
    border-bottom: none;
}

.profile-list li:hover {
    background-color: #f8f8f8;
}

.profile-list .checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    color: #333;
}

.profile-list .checkbox-label input[type="checkbox"] {
    margin-right: 1rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #ff8000;
}

/* --- Nuevos Estilos para Asignación de Opciones a Perfiles --- */
.options-assignment-container {
    background-color: #ffffff;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    max-width: 900px;
    margin: 1rem auto;
}

.menu-option-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.menu-option-row:last-child {
    border-bottom: none;
}

.menu-option-name {
    font-weight: 500;
    color: #333;
    flex-basis: 25%;
    min-width: 120px;
}

.role-checkboxes {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    flex-grow: 1;
}

.role-checkboxes .checkbox-label {
     display: flex;
     align-items: center;
     cursor: pointer;
     font-size: 0.95rem;
     color: #333;
}

.role-checkboxes .checkbox-label input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #ff8000;
}

.options-assignment-container .btn-primary {
    margin-top: 1.5rem;
    float: right;
}

/* Estilos para el panel colapsable en la pestaña de Niveles del Catálogo */
.collapsible-panel {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 2rem;
    background-color: #fdfdfd;
}

.collapsible-panel summary {
    padding: 1rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none; /* Elimina el marcador por defecto */
    color: #333333;
    position: relative;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
}

.collapsible-panel summary:hover {
    background-color: #f8f8f8;
}

.collapsible-panel summary::before {
    content: '▶';
    font-size: 0.8em;
    margin-right: 0.75rem;
    display: inline-block;
    transition: transform 0.2s;
}

.collapsible-panel[open] > summary::before {
    transform: rotate(90deg);
}

.panel-form {
    padding: 0 1.5rem 1.5rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 1rem;
}

.panel-form .btn-primary {
    margin-top: 1rem;
}

.table-title {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333333;
}

/* Estilos para la Vista de Árbol en la pestaña de Elementos del Catálogo */
.tree-controls {
    margin-bottom: 1.5rem;
}

.tree-container {
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #ffffff;
    min-height: 200px;
    overflow-x: auto;
}

.tree-container ul {
    list-style-type: none;
    padding-left: 25px;
    margin: 0;
    position: relative;
}

/* Líneas del árbol */
.tree-container ul::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 10px;
    width: 1px;
    background: #e0e0e0;
}

.tree-node {
    margin: 5px 0;
    position: relative;
}

/* Línea horizontal hacia el nodo */
.tree-node > .node-content::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -15px;
    height: 1px;
    width: 15px;
    background: #e0e0e0;
}

.node-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.node-content:hover {
    background-color: #f8f8f8;
}

.node-toggle {
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    border: none;
    background: transparent;
    padding: 0;
}

.node-toggle.is-leaf {
    visibility: hidden; /* Oculta el toggle para nodos hoja */
}

.node-toggle .icon {
    width: 20px;
    height: 20px;
    transition: transform 0.2s;
}

.tree-node.collapsed > .node-content .node-toggle .icon {
    transform: rotate(-90deg);
}

.tree-node.collapsed > ul {
    display: none;
}

.node-text {
    flex-grow: 1;
    font-size: 1rem;
    color: #333333;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid transparent;
}

.node-text[contenteditable="true"] {
    border-color: #ff8000;
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 128, 0, 0.2);
}

.node-actions {
    display: flex;
    gap: 5px;
    visibility: hidden;
}
.node-content:hover .node-actions {
    visibility: visible;
}

/* --- Overlay para el menú móvil --- */
.sidebar-overlay {
    display: none; /* Oculto por defecto */
}
body.sidebar-mobile-open .sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1999; /* Debajo del sidebar, encima del contenido */
    cursor: pointer;
    animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Estilos para el Modal de Sesión Expirada --- */
.session-expired-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInOverlay 0.3s ease;
}

.session-expired-modal {
    background: #ffffff;
    padding: 2rem 3rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 450px;
    width: 90%;
    z-index: 9999;
    animation: fadeInContent 0.4s ease-out;
}

.session-expired-modal h2 {
    color: #333333;
    font-size: 1.8rem;
    margin-top: 0;
    margin-bottom: 1rem;
}

.session-expired-modal p {
    color: #666666;
    font-size: 1rem;
    margin-bottom: 2rem;
}

.session-expired-modal .btn-primary {
    width: auto;
    padding: 0.8rem 2.5rem;
}


/* --- Lógica de Sidebar en Escritorio --- */
@media (min-width: 901px) {
    body.sidebar-collapsed .dashboard-container {
        grid-template-columns: 0 1fr;
    }

    body.sidebar-collapsed .sidebar {
        padding-left: 0;
        padding-right: 0;
        border-right-width: 0;
        visibility: hidden;
    }

    body.sidebar-collapsed #open-sidebar-btn {
        display: flex;
    }
}


/* --- Lógica de Sidebar en Móvil --- */
@media (max-width: 900px) {
  body {
    padding-top: 60px;
    height: auto;
  }

  .dashboard-container {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 60px);
    transition: none;
  }

  /* Anular el colapso de escritorio en móvil */
  body.sidebar-collapsed .dashboard-container {
      grid-template-columns: 1fr;
  }
   body.sidebar-collapsed .sidebar {
      visibility: visible;
      padding: 1.5rem 1rem;
      border-right-width: 1px;
  }

  /* Comportamiento del sidebar como un panel deslizable */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    border-right: 1px solid #e0e0e0;
    border-bottom: none;
  }
  
  body.sidebar-mobile-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0px 15px rgba(0,0,0,0.1);
  }
  
  .sidebar-header {
      display: flex;
  }

  #open-sidebar-btn {
      display: flex;
  }

  .sidebar-footer {
    margin-top: 1.5rem;
  }

  .main-content {
    padding: 2rem;
  }

  .top-toolbar {
    padding: 0 1rem;
  }

  .page-header h1 {
    font-size: 1.8rem;
  }

  .user-form,
  .options-assignment-container {
    padding: 1.5rem;
  }

  .tabs {
    margin-bottom: 1.5rem;
  }

  .tab-link {
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
  }
  
  .assignment-container {
    grid-template-columns: 1fr;
    padding: 1.5rem;
  }
}