/* ============================================
   ÁRBOL ACADÉMICO INTERACTIVO — CSS
   ============================================ */

.arbol-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #222B3A;
}

.arbol-titulo {
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.btn-primario {
  background: linear-gradient(135deg, #FF4D8D, #D30000);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primario:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 77, 141, 0.4);
}

.btn-secundario {
  background: #1A2230;
  color: #8B95A5;
  border: 1px solid #2A3441;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secundario:hover {
  background: #222B3A;
  color: #E8ECF1;
}

.btn-peligro {
  background: rgba(211, 0, 0, 0.15);
  color: #FF4D4D;
  border: 1px solid rgba(211, 0, 0, 0.3);
}

.btn-peligro:hover {
  background: rgba(211, 0, 0, 0.25);
}

.btn-icono {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #8B95A5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-icono:hover {
  background: #2A3441;
  color: #ffffff;
}

.btn-icono.btn-peligro:hover {
  background: rgba(211, 0, 0, 0.15);
  color: #FF4D4D;
}

.btn-icono.btn-agregar {
  background: rgba(255, 77, 141, 0.1);
  color: #FF4D8D;
}

.btn-icono.btn-agregar:hover {
  background: rgba(255, 77, 141, 0.2);
}

/* Nodos del árbol */
.arbol-nivel {
  position: relative;
}

.arbol-nodo {
  position: relative;
  margin-bottom: 4px;
}

.arbol-nodo[data-nivel="0"] { margin-left: 0; }
.arbol-nodo[data-nivel="1"] { margin-left: 28px; }
.arbol-nodo[data-nivel="2"] { margin-left: 56px; }
.arbol-nodo[data-nivel="3"] { margin-left: 84px; }

.nodo-conector {
  position: absolute;
  left: -14px;
  top: 0;
  width: 14px;
  height: 24px;
  border-bottom: 2px solid #2A3441;
  border-left: 2px solid #2A3441;
  border-bottom-left-radius: 6px;
}

.arbol-nodo[data-nivel="0"] .nodo-conector { display: none; }

.nodo-cabecera {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #1A2230;
  border-radius: 10px;
  border-left: 3px solid;
  transition: all 0.2s ease;
  cursor: default;
}

.nodo-cabecera:hover {
  background: #222B3A;
  transform: translateX(2px);
}

.nodo-inactivo .nodo-cabecera {
  opacity: 0.6;
  border-left-color: #666 !important;
}

.nodo-toggle {
  cursor: pointer;
  width: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: #8B95A5;
  user-select: none;
  transition: transform 0.2s;
}

.nodo-toggle-vacio {
  cursor: default;
  color: #3A4556;
}

.nodo-icono {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.nodo-nombre {
  flex: 1;
  font-weight: 500;
  color: #E8ECF1;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nodo-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-right: 8px;
}

.nodo-orden {
  font-size: 0.75rem;
  color: #5A6578;
  background: #0F141D;
  padding: 2px 8px;
  border-radius: 12px;
  font-family: monospace;
}

.nodo-estado-inactivo {
  font-size: 0.7rem;
  color: #FF9500;
  background: rgba(255, 149, 0, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nodo-acciones {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.nodo-cabecera:hover .nodo-acciones {
  opacity: 1;
}

.nodo-hijos {
  padding-top: 4px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.activo {
  opacity: 1;
  pointer-events: all;
}

.modal-panel {
  background: #1A2230;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  border: 1px solid #2A3441;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  color: #E8ECF1;
  font-size: 1.2rem;
}

.btn-cerrar {
  background: none;
  border: none;
  color: #8B95A5;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

.btn-cerrar:hover {
  color: #E8ECF1;
}

.campo-formulario {
  margin-bottom: 16px;
}

.campo-formulario label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #8B95A5;
  font-weight: 500;
}

.campo-formulario input,
.campo-formulario select {
  width: 100%;
  padding: 10px 12px;
  background: #0F141D;
  border: 1px solid #2A3441;
  border-radius: 8px;
  color: #E8ECF1;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.campo-formulario input:focus,
.campo-formulario select:focus {
  outline: none;
  border-color: #FF4D8D;
}

.ayuda-campo {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: #5A6578;
}

.modal-acciones {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Drawer de Impacto */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.drawer-overlay.activo {
  opacity: 1;
  pointer-events: all;
}

.drawer-panel {
  background: #1A2230;
  border-radius: 16px 16px 0 0;
  padding: 24px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid #2A3441;
  border-bottom: none;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.drawer-header h3 {
  margin: 0;
  color: #E8ECF1;
}

.impacto-resumen {
  background: rgba(211, 0, 0, 0.05);
  border: 1px solid rgba(211, 0, 0, 0.2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.impacto-resumen p {
  margin: 0;
  color: #E8ECF1;
  font-size: 0.95rem;
}

.impacto-total {
  margin-top: 8px !important;
  color: #FF4D8D !important;
  font-weight: 500;
}

.arbol-impacto {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  background: #0F141D;
  border-radius: 8px;
  padding: 12px;
}

.lista-impacto {
  list-style: none;
  padding: 0;
  margin: 0;
}

.item-impacto {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #1A2230;
}

.item-impacto:last-child {
  border-bottom: none;
}

.item-icono {
  font-size: 1rem;
}

.item-nombre {
  flex: 1;
  color: #E8ECF1;
  font-size: 0.9rem;
}

.item-tipo {
  font-size: 0.75rem;
  color: #5A6578;
  background: #1A2230;
  padding: 2px 8px;
  border-radius: 12px;
}

.impacto-vacio {
  color: #5A6578;
  font-size: 0.9rem;
  text-align: center;
  padding: 20px;
}

.confirmacion-eliminacion {
  border-top: 1px solid #2A3441;
  padding-top: 20px;
}

.confirmacion-eliminacion p {
  margin: 0 0 12px 0;
  color: #8B95A5;
  font-size: 0.9rem;
}

.confirmacion-eliminacion input,
.confirmacion-eliminacion select {
  width: 100%;
  padding: 10px 12px;
  background: #0F141D;
  border: 1px solid #2A3441;
  border-radius: 8px;
  color: #E8ECF1;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.confirmacion-eliminacion input:focus,
.confirmacion-eliminacion select:focus {
  outline: none;
  border-color: #D30000;
}

.drawer-acciones {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Estados */
.cargando-arbol {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #5A6578;
}

.estado-vacio {
  text-align: center;
  padding: 60px 20px;
  color: #5A6578;
}

.estado-vacio p:first-child {
  font-size: 1.1rem;
  color: #8B95A5;
  margin-bottom: 8px;
}

.texto-secundario {
  font-size: 0.9rem;
  color: #5A6578;
  margin-bottom: 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #2A3441;
  border-top-color: #FF4D8D;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

/* Responsive */
@media (max-width: 768px) {
  .nodo-acciones {
    opacity: 1;
  }
  
  .nodo-cabecera {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .nodo-meta {
    width: 100%;
    justify-content: flex-start;
  }
  
  .arbol-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}

/* ============================================
   TABLA DE USUARIOS
   ============================================ */

.tabla-usuarios {
  background: #1A2230;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #2A3441;
}

.tabla-header {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 12px 16px;
  background: #0F141D;
  font-size: 0.75rem;
  font-weight: 600;
  color: #8B95A5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tabla-fila {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #222B3A;
  align-items: center;
  transition: background 0.2s;
}

.tabla-fila:hover {
  background: #222B3A;
}

.tabla-fila:last-child {
  border-bottom: none;
}

.usuario-nombre {
  font-weight: 600;
  color: #E8ECF1;
}

.usuario-email {
  font-size: 0.85rem;
  color: #8B95A5;
}

.badge-rol {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-superadmin {
  background: rgba(255, 215, 0, 0.15);
  color: #FFD700;
}

.badge-director {
  background: rgba(255, 77, 141, 0.15);
  color: #FF4D8D;
}

.badge-profesor {
  background: rgba(74, 144, 217, 0.15);
  color: #4A90D9;
}

.badge-auxiliar {
  background: rgba(80, 200, 120, 0.15);
  color: #50C878;
}

.badge-estudiante {
  background: rgba(139, 149, 165, 0.15);
  color: #8B95A5;
}

.usuario-estado {
  font-size: 0.8rem;
  color: #50C878;
}

.usuario-acciones {
  display: flex;
  gap: 4px;
}
